No library solutions, please, though if you know of one that does this, I'm happy to take a look at how they do it. Not terribly concerned with fall-backs and cross browser support.
I have a hierarchy (that will change):
<body>
<div></div>
<div>
<div></div>
<div></div>
<div>
<a>Click Me!</a>
</div>
</div>
</body>
I have an event listener on <a>Click Me!</a>
and get an event object back. That much works. YEY!
I want the event.target
dom hierarchy numerical index. basically, [0][1][2][0]
(though it would probably return as an array, [0,1,2,0]
, and that's okay with me).
I know this can be done with iterating through the parent elements. I'm trying to avoid that iteration, if possible.
EDIT Redacting my last edit as an act of idiocy.