I have two element like this:
<div id="first">
<div id="test"></div>
</div>
<div id="second">
<div id="test"></div>
</div>
then i want to getElementbyId(‘test’), However I need ‘test’ in first div.
meanwhile this is an example and my div doesn’t have pre-defined order.
user1689607’s comment re multiple ID’s withstanding, assuming your html shown above is verbatim (that is to say, you can identify the container divs with a class or id as you have)
This works fine, tested in chrome.