开发者

Function only works on one div?

I am stuck... I can't开发者_如何学运维 seem to get a function to fire off on the divs below the first one.... any suggestions?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜