[英]jQuery opposite of “starts with” selector: [^=]
I have some div tag below: 我在下面有一些div标签:
<div class="magazine"></div>
<div class="newsletter"></div> // I need to take this div
<div class="may-moon"></div>
If I needed div with class start with " ma ", I would use $('div[class^="ma"]')
, but what is opposite? 如果我需要以“ ma ”开头的div,我会使用
$('div[class^="ma"]')
,但是相反的是什么? thanks. 谢谢。
相反的是使用jQuery:not() :
$('div:not([class^="ma"])')
您可以使用负面过滤功能“ 不 ”如下: $('div').not('[class^="ma"]')
,或否定选择器“ :not ”,如下所示: $('div:not([class^="ma"])')
(正如Karl-AndréGagnon指出的那样)
You need to use :not() Selector
for this. 您需要使用
:not() Selector
。 because there is no exact opposite selector exist of [^=]
and *
in jquery. 因为在jquery中没有
[^=]
和*
存在完全相反的选择器。
:not() Selector - Selects all elements that do not match the given selector.
See more about Jquery selectors 查看有关Jquery选择器的更多信息
There a opposite selector exist !
有一个相反的选择器存在
!
- -
Attribute Not Equal Selector [name!="value"] - Select elements that either don’t have the specified attribute, or do have the specified attribute but not with a certain value.
but use of this !
但是使用这个
!
selector, you need to provide full-name of class. 选择器,你需要提供类的全名。
$('div[class!="magazine"][class!="may-moon"]')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.