Is there a way to get the deepest element matching a contains statement?
Basicly if I have nested divs, I want the last element not the parent element:
<div id="hayStack">
<div id="needle">Needle</div>
</div>
$("div:contains('Needle')")
is returning the hayStack div.
The only solution I have come up with so far is explicitly exlcuding parent divs by their id with .not
Adding :last
will return the deepest/last div (the one immedietly encapsulating the content you are searching for
$("div:contains('Needle'):last")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With