+ 19
[SOLVED] Toggle effect
I want to change the background color each time I click on the box. How can I do that? I've been trying to do that with if statement but it didn't work. Here's the code https://code.sololearn.com/W5QHMMczGPw4/?ref=app
2 RĂ©ponses
+ 12
Add the following code in script tag:
function myfunc(){
document.getElementsByTagName("body")[0].classList.toggle("change");
}
Add a class in css
.change {
background-color: aqua;
}
+ 14
It works!!! đđđ
Thanks a lot Ankit đđ