I want to get an element that contains specific text. When I use the :contains selector, the result is also all of the parents elements of that specific element.
Also, if there is more than on element that actually contains the text, the result of the selector is very cumbersome. Is it possible to get only the elements themselves which contains the specific text?
Thanks,
Joel
EDIT:
Example:
<body>
<div>
<div>
<div>text</div>
</div>
</div>
</body>
and $(“div:contains(‘text’)”) results in:
[<div>…</div>, <div>…</div>, <div>text</div>]
I want a way to only get the <div>text</div> element. (I know I can use .get(-1) to get that last element, but I want to know if there is something more gemeric).
You can try something like: