Reputation: 1239
I'm tryting to use the JQuery to find and remove the <li>
<a href="/arb/node/53/grouping/edit/">Edit group</a>
</li>
with no luck at all.
Could please let me know to achieve this.
<ul class="tabs secondary">
<li class="active">
<a href="/arb/node/53/grouping">View</a>
</li>
<li>
<a href="/arb/node/53/grouping/add">Add new Group</a>
</li>
<li>
<a href="/arb/node/53/grouping/edit/">Edit group</a>
</li>
</ul>
I try the following jquery, but it not work.
$(".tabs.secondary:contains(\"Edit group\")").remove()
The right solutions should be something that will find the word "Edit group" and remove it <li>
parent.
Thanks
Finau
Upvotes: 4
Views: 41878
Reputation: 30453
If you are using jQuery:
$('.tabs li:has(a[href="/arb/node/53/grouping/edit/"])').remove()
to remove it.
Edit: since the number in the path is dynamic, you can probably use the following:
$('.tabs li:has(a[href$="/edit/"])').remove()
which will only remove the URL path that ends with /edit/
.
Upvotes: 7
Reputation: 42612
$("li:has('a'):contains('Edit group')").remove();
Demo: http://jsfiddle.net/YqFfe/
Upvotes: 10
Reputation: 1127
$('a').each(function() {
if ($.trim($(this).text()) == 'Edit Group') {
$(this).parent().remove();
}
});
Edited to target text.
Upvotes: 2
Reputation: 3194
Also you can try:
$('li:eq(2)').remove();
$('.tabs li:eq(2)').remove();
Upvotes: 2