Where to find the standard of work in getElementById?

0 like 0 dislike
8 views
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...

<html>
the <head>
<title></title>
<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
}
</script>
</head>
the <body>
<a href="#" onclick="ondivclick()">Go!</a>
<div id="place"></div>
</body>
</html>


* This source code was highlighted with Source Code Highlighter.
by | 8 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.
by

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,186 answers
0 comments
28,660 users