Monday, July 29, 2019

javascript - Uncaught TypeError: Cannot set property 'onclick' of null

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;



Form!
















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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...