<div id="myDIV">
<div>
<span>
<a href="#">Seek me!</a>
</span>
</div>
</div>
How can I find A tag using jQuery selector (not looping through children())
If I know only myDIV id.
Well, it really sounds a bit awkward. For example I’ve clicked #myDIV and i need to get text from the last child tag. It could A, span, div, p, whatever. Also myDIV could not even have any children elements.
Excuse me my English
Like this:
This will find all the last “leaf” elements, you could restrict to only
<a>, etc if you wanted. For your markup::emptydoesn’t work here (because it has a text node child), but finding things with no child elements will, here’s an example page showing this.