Where to find the standard of work in getElementById?

0 like 0 dislike
In General the question is simple. Why, when you add a document 2 elements with the same id, it takes the first element and not the second?

PS I Understand that for this it is necessary to hand off, but all the same...

the <head>
<script type="text/javascript">
function ondivclick() {
document.getElementById("place").innerHTML += "1";
document.getElementById("place").innerHTML += "2";
alert(document.getElementById("divid").innerHTML); // here on all browsers will be 1
the <body>
<a href="#" onclick="ondivclick()">Go!</a>
<div id="place"></div>

* This source code was highlighted with Source Code Highlighter.
by | 27 views

1 Answer

0 like 0 dislike
It is logical to assume that due to the fact that it is assumed that the document id is unique, the search by id finding it, the search is terminated. Sense to sort items further, if the standard second can not be.

Related questions

0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
40,796 users