How to exclude elements in jquery

WBOY
Release: 2022-04-02 17:30:31
Original
2180 people have browsed it

In jquery, you can use the not() method to exclude specified elements. The function of this method is to return elements that do not meet certain conditions. Elements that do not meet the conditions will be returned from the selection, and elements that meet the conditions will be returned. is excluded, the syntax is "element object.not(criteria,function(index))".

How to exclude elements in jquery

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

How to exclude elements in jquery

You can use the not() method to exclude elements.

not() method returns elements that do not meet certain conditions.

This method lets you specify a condition. Elements that do not meet the criteria will be returned from the selection, and elements that meet the criteria will be removed.

This method is usually used to remove one or more elements from the selected element combination.

Tip: The not() method is opposite to the filter() method.

Syntax

$(selector).not(criteria,function(index))
Copy after login

criteria Optional. Specifies a selector expression, jQuery object, and one or more elements to be removed from the selected set of elements. If you need to specify multiple conditions, separate them with commas.

function(index) Optional. Specifies the function to be run for each element in the combination. If true is returned, the element is removed, otherwise the element is retained. index - the index position of the element in the collection.

The example is as follows:

    123   

欢迎来到我的主页

我的名字叫 Donald。

我住在 Duckburg。

我爱 Duckburg。

我最好的朋友是 Mickey。

Copy after login

Output result:

How to exclude elements in jquery

Related video tutorial recommendation:jQuery video Tutorial

The above is the detailed content of How to exclude elements in jquery. For more information, please follow other related articles on the PHP Chinese website!

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!