I am stuck... I can't seem to get a function to fire off on the divs below the first one.... any suggestions?
+3
A:
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.
Sohnee
2009-11-26 09:04:08
By rights having two ids that are the same makes the html invalid so each id should be unique so the problem above should not occur.
matpol
2009-11-26 09:24:37
I think I mentioned that already in my answer.
Sohnee
2009-11-27 08:48:12