tags:

views:

21

answers:

2

I'm brand new to jquery and am not even sure if I'm referring correctly 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>
A: 
$('.remove').remove()
Nicolas Bottarini
A: 

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

Reigel
Hi Reigel, thanks for this.. I'm going to try this now.
jim
Reigel, that worked, thank you. Also, thank you for the comments in the code, it helps me understand.
jim
no problem... welcome to [SO](http://stackoverflow.com/) ;)
Reigel
Thank you, Reigel. I'm sure I'll be back often. :)
jim