i'm getting uncaught type error of:
Uncaught TypeError: Cannot set property 'onclick' of null
dice app
js code:
var button = document.getElementById("button");
button.onclick = function() {// error
var print = dice.roll();
printNumber(print);
};
Answer
You're executing your JavaScript before the elements exist. Either move your code to the end of the page or put it within an onload handler.
Ex:
dice app
No comments:
Post a Comment