Reputation: 1
I am stuck... I can't seem to get a function to fire off on the divs below the first one.... any suggestions?
Upvotes: 0
Views: 168
Reputation: 250882
Perhaps you are using something like this:
document.getElementById("myDiv")
With HTML like this:
<div id="myDiv">Hello World</div>
<div id="myDiv">Hello Again</div>
In which case, you can't use the same ID for two div tags and the divs after your first one won't be affected by your JavaScript.
You can use:
document.getElementsByTagName("div")
To get a collection of all your divs, you could then test them to see if you want to do something with them, for example by giving them all the same class.
Upvotes: 3