I have a DOM tree:
<div id="all">
<div id="second">
<div id="target"></div> *
<div id="somediv"></div>
</div>
<div id="second">
<div id="target"></div>
<div id="somediv"></div>
</div>
<div id="second">
<div id="target"></div>
<div id="somediv"></div>
</div>
</div>
How I can get all divs with id=”target”?
$('#second').siblings().andSelf().children(':first') – shows only the first target (*), ignoring the rest.
You can’t have multiple divs with the same ID in an HTML document. Instead, use class=”target”. Then you can get all divs with the class target in all with