+ 2
You have to use a event handler that triggers your code everytime someone clicks the checkbox. add onchange="onChangeHandler()" to your input as attribute and wrap your java script into a function. so everytime the checkbox changes the code is executed also you have to assign the dom element to a variale to use it ! just calling it will do nothing :)
30th Sep 2017, 3:53 PM
Chrizzhigh
Chrizzhigh - avatar
+ 2
i quickly wrote one myself : function handler(){ var checkbox = document.getElementById("check"); var body = document.getElementById("body"); if( checkbox.checked){ body.style.backgroundColor="#000000"; }else{ body.style.backgroundColor="#FFFFFF"; } }
30th Sep 2017, 4:01 PM
Chrizzhigh
Chrizzhigh - avatar
+ 2
i see no error in your code ? did you fixed it ? ^^
30th Sep 2017, 4:13 PM
Chrizzhigh
Chrizzhigh - avatar
30th Sep 2017, 4:06 PM
CalviŐČ
CalviŐČ - avatar
+ 1
i think the answer of the question has some links on it https://stackoverflow.com/questions/4148499/how-to-style-a-checkbox-using-css
30th Sep 2017, 4:20 PM
Chrizzhigh
Chrizzhigh - avatar