jQuery 如何删除具有特定类名的所有 div?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7048113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 23:20:14  来源:igfitidea点击:

How can i delete all divs with a certain class name?

jquerycss-selectors

提问by leora

Using jquery, what is the best way to delete all divs with a certain class name ? (I don't want to just hide the div but fully delete it). So if I have this code:

使用 jquery,删除具有特定类名的所有 div 的最佳方法是什么?(我不想只是隐藏 div 而是完全删除它)。所以如果我有这个代码:

<div class="Test" ><div class="ABC" ><div class="Test" >

after I call this method where class = "Test", i would just see:

在我调用这个方法 where class = "Test" 之后,我会看到:

<div class="ABC" >

回答by Joseph Marikle

$("div.Test").remove();

That'll do it.

这样就可以了。