How to differentiate between :not() selector in css and .not() method in jQuery? (code example)

青灯夜游
Release: 2018-10-24 17:52:51
forward
2351 people have browsed it

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可叠加使用
Copy after login

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元素
Copy after login

Two ways to select the input element of class!=test

$(input:not(.test)).css(...);$(input).not(".test").css(...);
Copy after login

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】:

CSS3 video tutorial

jQuery video tutorial

bootstrap video tutorial

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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template