jquery – 如何删除没有指定类的元素

我有一个很棒的 HTML页面.一些元素(可以是p,h1,div等)用类’keep_me’标记.
我需要删除页面中没有这个类的所有元素吗?关于如何使用jQuery做任何想法?

我试过类似的东西,但它不起作用(显然;):

jQuery('#content *').remove(":not('[class=keep_me]')");

解决方法

做就是了:
jQuery('#content :not(.keep_me)').remove();

documentation

jQuery(‘:not(selector)’)

Selects all elements that do not match the given selector.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...