JQuery,选择什么不包含某些东西

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14022208/
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 13:12:10  来源:igfitidea点击:

JQuery, selecting what does NOT contains something

jquerycontains

提问by user1722791

If i want to select what contains "pc" i use $('tr:contains("pc")')

如果我想选择包含“pc”的内容,我使用 $('tr:contains("pc")')

But what can i use to select what does NOT contains "pc"?

但是我可以用什么来选择不包含“pc”的内容?

回答by Ricardo Marimon

Use the :not() selectorthat is part of the jquery framework. Something like $('tr:not(:contains("pc"))')should do the trick.

使用 :not() 选择器,它是 jquery 框架的一部分。类似的东西$('tr:not(:contains("pc"))')应该可以解决问题。

回答by Chuck Norris

$('tr').not(':contains("pc")')

回答by Muhammad Talha Akbar

$('tr:not(:contains("pc"))') // this can be used

回答by Víctor Oliva

$("tr:not(:contains("pc"))")

$("tr:not(:contains("pc"))")

if you use simple quotes with double quotes mixed in the same sentence, it doesn't work

如果在同一个句子中使用单引号和双引号混合,则不起作用