Reputation: 1576
I've this code :
<span>
<a href="#">Hello world</a>
»
</span>
I want delete »
after the link.
I try this but it does not work.
jQuery(function ($) {
$('span a').nextAll('»').remove();
});
Thanks for the help !
Upvotes: 0
Views: 63
Reputation: 388316
One solution si to delete the last child of the span for that
$('span').contents().last().remove()
jQuery(function($) {
$('button').click(function(){
$('span').contents().last().remove();
})
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button>Remove</button>
<span>
<a href="#">Hello world</a>
»
</span>
To delete the next sibling of a
$($('span a')[0].nextSibling).remove()
Upvotes: 1