开发者

In jQuery, how do you remove all the divs pertaining to a certain class INSIDE a certain div class?

开发者 https://www.devze.com 2023-01-06 14:12 出处:网络
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:

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!!


$('div.test').find('div.delete').remove();

should do the trick for you


actually a combination of both:

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


To delete any div inside

$('div.test div').remove()


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消