So in my code, when you click on an element it will alert the name of the tag.
What I really want to do is find the path, so I could reference that element again later.
So for example, if I clicked the text "World" I'd get something like
DIV(2) > UL > LI (2)
I don't want to do this in jQuery, just plain old vanilla.
document.addEventListener("click", eOnClick, true);
function eOnClick(e) {
alert(e.target.tagName);
}
div {
border: 1px solid red;
}
ul {
border: 1px solid green;
}
li {
border :1px solid blue;
}
<div>
<div>
<ul>
<li>Hello
<li>World
</ul>
</div>
</div>