This should be simple:
<li>
<a href=""></a>
</li>
<li>
<a href="specific-url"></a>
</li>
I want to select that <li>
based on the <a>
tag's attribute with specific url in the href. (Do not use last-child
)
How can I?
As simple as:
$('a[href="specific-url"]').parent('li');
Here you go:
$('li:has(a[href="specific-url"])')
Live DEMO
Another way is:
$('li > a[href="specific-url"]').parent()
Live DEMO
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