You can look up an element's DOM position via document.getElementsByTagName("a")[x]
, but is it possible to find that x value somewhere in its list of attributes?
If I have
<a>z</a> <!-- 0 -->
<a>2</a> <!-- 1 -->
<a>potato</a> <!-- 2 -->
These are the order of them according to the DOM. I'm trying to find if there is an attribute attached to those that contains their DOM position.