jQuery getting the item that called the function and removing it's parent
I have a function that removes the item, cod开发者_如何学编程e looks like this
<li><a onclick="remove('9', 1);">Remove</a></li>
With jquery, how would I remove the whole 'li' when remove is clicked?
Thank you!
Instead of the onClick event I'd prefer to use the following way:
<li><a id="remove">Remove</a></li>
$('#remove').click(function(){
$(this).parent().remove();
});
Something similar to following:
$("a").click(function() {
$(this).parent("li").remove();
});
The "a"
selector likely needs to be changed to match the exact <a>
elements you want.
精彩评论