+ 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 :)
+ 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";
}
}
+ 2
i see no error in your code ? did you fixed it ? ^^
+ 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