I have the following code, which basically toggles through a bunch of images.
Press Here!
For some reason, when I run it, nothing happens, because of the following error as displayed by my Firebug console.
hbutton is undefined
---
hbutton.onclick = function() {
When I run just the JS after the page has loaded however, it works perfectly fine!!! Why is this?
Answer
Your code is executing before the h1 tag is defined. You must run it in an onload handler or put it just before /body
No comments:
Post a Comment