Answer the question
In order to leave comments, you need to log in
Where can I find the getElementById working standard?
In general, the question is simple. Why, when adding 2 elements with the same id to a document, is the first element taken, and not the second?
PS I understand that you have to tear off your hands for this, but still ...
<font color="black"><font color="#0000ff"><</font><font color="#800000">html</font><font color="#0000ff">></font><br/> <font color="#0000ff"><</font><font color="#800000">head</font><font color="#0000ff">></font><br/> <font color="#0000ff"><</font><font color="#800000">title</font><font color="#0000ff">></</font><font color="#800000">title</font><font color="#0000ff">></font><br/> <font color="#0000ff"><</font><font color="#800000">script</font> <font color="#ff0000">type</font><font color="#0000ff">="text/javascript"</font><font color="#0000ff">></font><br/> <font color="#0000ff">function</font> ondivclick() {<br/> <font color="#0000ff">document</font>.getElementById(<font color="#A31515">"place"</font>).innerHTML += <font color="#A31515">"1"</font>;<br/> <font color="#0000ff">document</font>.getElementById(<font color="#A31515">"place"</font>).innerHTML += <font color="#A31515">"2"</font>;<br/> alert(<font color="#0000ff">document</font>.getElementById(<font color="#A31515">"divid"</font>).innerHTML); <font color="#008000">// тут на всех браузерах будет 1</font><br/> }<br/> <font color="#0000ff"></</font><font color="#800000">script</font><font color="#0000ff">></font><br/> <font color="#0000ff"></</font><font color="#800000">head</font><font color="#0000ff">></font><br/> <font color="#0000ff"><</font><font color="#800000">body</font><font color="#0000ff">></font> <br/> <font color="#0000ff"><</font><font color="#800000">a</font> <font color="#ff0000">href</font><font color="#0000ff">="#"</font> <font color="#ff0000">onclick</font><font color="#0000ff">="ondivclick()"</font><font color="#0000ff">></font>Go!<font color="#0000ff"></</font><font color="#800000">a</font><font color="#0000ff">></font><br/> <font color="#0000ff"><</font><font color="#800000">div</font> <font color="#ff0000">id</font><font color="#0000ff">="place"</font><font color="#0000ff">></</font><font color="#800000">div</font><font color="#0000ff">></font><br/> <font color="#0000ff"></</font><font color="#800000">body</font><font color="#0000ff">></font><br/> <font color="#0000ff"></</font><font color="#800000">html</font><font color="#0000ff">></font></font><br/> <br/> <font color="gray">* This source code was highlighted with <a href="http://virtser.net/blog/post/source-code-highlighter.aspx"><font color="gray">Source Code Highlighter</font></a>.</font>
Answer the question
In order to leave comments, you need to log in
It is logical to assume that due to the fact that it is assumed that all ids in the document are unique, then when searching by id, finding it, the search stops. It makes sense to sort through the elements further if, according to the standard of the second, this cannot be.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question