I'm having problems making my window alert pop up with a simple checkbox and can't for the life of me figure out why. Here's the basic Javascript and HTML:
var blue_box=document.getElementById("color-blue");
function colorFunction() {
window.alert("This color is blue!");
}
blue_box.onclick=colorFunction;
Which throws: Uncaught TypeError: Cannot set property 'onclick' of null
under
blue_box.onclick=colorFunction;
Are there any visible reasons for this error in my code?
No comments:
Post a Comment