Exercise 11.2

This commit is contained in:
Karan 2021-11-24 22:19:00 +05:30 committed by GitHub
parent dcf4b32022
commit 8e9e6edbd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

17
Chapter 11/Exercise 11.2 Normal file
View File

@ -0,0 +1,17 @@
<!doctype html>
<html>
<body>
<div>red</div>
<div>blue</div>
<div>green</div>
<div>yellow</div>
<script>
const divs = document.querySelectorAll("div");
divs.forEach((el)=>{
el.addEventListener("click",()=>{
document.body.style.backgroundColor = el.textContent;
})
})
</script>
</body>
</html>