New course! Every coder should learn Generative AI!
Try a free lesson+ 3
Why can't I change backgroundcolor and return to the normal color with input checkbox using Js, I'm confused guys please help
3 Answers
+ 1
if(document.getElementById("range").checked == true) ☑️
if(document.getElementById("range").value=true) ❎
You forgot to implement the else condition's body too.
+ 3
Use the "checked" property instead of "value" to get the current state of the checkbox.
Also remember that = is used for assignments only. Use == or === for comparison.
+ 1
I tried == no result