behavior of javascript getElementById() when there are elements with duplicate IDs in HTML DOM?

后端 未结 5 1332
感动是毒
感动是毒 2020-12-04 01:42

Can someone shed some light on the behavior of javascript getElementById() when there are elements with duplicate IDs in HTML DOM??

5条回答
  •  时光说笑
    2020-12-04 02:39

    While there is no standard behavior defined, typically it will return the first element found.

    Demo: http://jsfiddle.net/ruNKK/

提交回复
热议问题