jQuery与“starts with”选择器相反:

我在下面有一些div标签:

// I need to take this div

如果我需要以“ ma ”开头的div,我会使用$('div[class^="ma"]') ,但是相反的是什么? 谢谢。

相反的是使用jQuery:not() :

 $('div:not([class^="ma"])') 

您可以使用负面过滤function“ 不 ”,如下所示: $('div').not('[class^="ma"]') ,或否定选择器“ :not ”,如下所示: $('div:not([class^="ma"])') (正如Karl-AndréGagnon指出的那样)

你需要使用:not() Selector 。 因为在jquery中没有[^=]*存在完全相反的选择器。

 :not() Selector - Selects all elements that do not match the given selector. 

查看有关Jquery选择器的更多信息

有一个相反的选择器存在!

 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. 

但是使用这个! 选择器,您需要提供类的全名。

 $('div[class!="magazine"][class!="may-moon"]') 

试试这个