How can I delete list element if it has a child link of some defined id ? So looking at the code below I’d like to find a <li> with <a> of id=link1 and delete this li.
<li class="nav-tab">
<a href="#link1">Component</a>
</li>
I’ve tried the code below but it doesn’t work :
$(function() {
$('.nav-tab:has(#link1)').css('display', 'none');
});
Your question and your code contradict each other, so I’ll provide answers for both cases.
If you want to remove a
<li class="nav-tab">that contains a child<a href="#link1">:If you want to remove a
<li class="nav-tab">that contains a child<a id="link1">: