Home >Web Front-end >CSS Tutorial >How to differentiate between :not() selector in css and .not() method in jQuery? (code example)
The content of this article is to introduce how to distinguish the :not() selector in css and the .not() method in jQuery? (code example). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Because I always confuse the two not methods, I wrote a memo.
Usage of :not() selector in css
:not pseudo-class selector can filter elements that do not match the expression, :not (selector) The selector is the css selector
ul li:not(:first-child) ul li:not(.text) //不包含class="text"的元素 :not(p) //非段落元素 ul li:not(:first-child):not(:last-child) //not可叠加使用
jQuery’s .not() method
not() from the set of matching elements Delete elements.
$("p").not("#selected") //选择id!=selected的段落元素 $('li').not(':even').css('background-color', 'red'); //选择不是偶数的li元素
Two ways to select the input element of class!=test
$(input:not(.test)).css(...);$(input).not(".test").css(...);
Summary: The above is the css introduced in this article: not() selector and jQuery .not() Method, I hope it will be helpful to everyone's study.
【More related tutorial recommendations】:
The above is the detailed content of How to differentiate between :not() selector in css and .not() method in jQuery? (code example). For more information, please follow other related articles on the PHP Chinese website!