views:

32

answers:

4

If I have a div that contains other divs, how do I make it so I remove all the divs inside the original div? That might have been confusing, heres a code example:

<div class="test"><div class="delete"></div></div>
<div class="delete"></div>

How do I remove the 'delete' div thats INSIDE the 'test' div ONLY and still keep the one outside. Thanks!!

+3  A: 
$('div.test').find('div.delete').remove();

should do the trick for you

Boycs
A: 

To delete any div inside

$('div.test div').remove()
redsquare
+1  A: 

actually a combination of both:

$('div.test div.delete').remove();
A: 

If you're sure there won't be any other children elements that has a .delete class, you can get away with this:

$('div.test > .delete').remove();
Gert G