I'm brand new to jquery and am not even sure if I'm referring cor开发者_高级运维rectly to the "parent" element. I want to remove the two <li>
tags completely. Is there a way to do this with only a single id declaration?
<li class="remove"><a href="#">ds</a></li>
<li class="remove"><a href="#">xfg</a></li>
<li><a href="#">ds</a></li> <------This stays as well as the one below
<li><a href="#">xfg</a></li>
you can do
$('.remove').remove(); // all which matches a class="remove" will be gone completely.
or by click of it's <a>
$('#ulID li a').click(function(){
$(this).closest('.remove').remove();
return false; // prevent link to jump to a page.
});
Welcome to stackoverflow.com
Don't forget to accept an answer
$('.remove').remove()
精彩评论