Home > Web Front-end > JS Tutorial > In jQuery: not selector usage example_jquery

In jQuery: not selector usage example_jquery

WBOY
Release: 2016-05-16 16:23:05
Original
1349 people have browsed it

The example in this article describes the usage of the not selector in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This selector removes elements from a collection of elements that match the given selector.

Grammar structure:

Copy code The code is as follows:
$(":not(selector)")

This selector is generally used in conjunction with other selectors, such as class selectors, element selectors, etc. . For example:
Copy code The code is as follows:
$("li:not(.second)").css("color" ,"green")

The above code sets the font color in the li element collection whose class name is not second to green.
If not used with other selectors, the default state is to be used with the * selector , for example, $(":not") is equivalent to $("*:not").

Parameter list:

参数 描述
selector 用于筛选的选择器。

Example code:

Example 1:

Copy code The code is as follows:






:not selector-Script Home






  • html area

  • div css area

  • jQuery Zone

  • Javascript Zone




Script House welcomes you


The sun is out




The above code can set the font color in the li element collection whose class attribute value is not second to green.

Example 2:

Copy code The code is as follows:






:not selector-Script Home






  • html area

  • div css area

  • jQuery Zone

  • Javascript Zone




Script House welcomes you


The sun is out




Since the above code does not specify a selector to be used with the :not selector, it is used with the * selector by default. Since the color attribute is inherited, the text of all elements will be set to green.

Readers who are interested in more content related to jquery selector can check out the special topic of this site: "Summary of jquery selector usage"

I hope this article will be helpful to everyone’s jQuery programming.

Related labels:
source:php.cn
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