Why can't I change backgroundcolor and return to the normal color with input checkbox using Js, I'm confused guys please help | Sololearn: Learn to code for FREE!
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

https://code.sololearn.com/Ww9AUJqEj17M/?ref=app

17th Jun 2020, 7:11 PM
Abat
Abat - avatar
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.
17th Jun 2020, 7:48 PM
Kevin ★
+ 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.
17th Jun 2020, 7:29 PM
Kevin ★
+ 1
I tried == no result
17th Jun 2020, 7:42 PM
Abat
Abat - avatar