Table of Contents
1. JQuery basic selector
3. Basic filter selector
5. Attribute filter (select elements containing specified attributes)
Home Web Front-end JS Tutorial Introduction to JQuery's various selectors

Introduction to JQuery's various selectors

Jun 26, 2017 am 11:55 AM
jquery study notes

1. JQuery basic selector

##$(".className")Class Selector$("tagName")Tag Selector$("*")Wildcard selector##$("tagName,.className,#idName,. ..")
express description remarks
$("#idName") id selector
Group Selector

2. Hierarchy Selector

Select nodes from the parent-child relationship and brother relationship.

express$("a b")(including child nodes and Grandchild node)##$("a>b")Select all child nodes b$("a+b")Select the first sibling node b## after node a Select all sibling nodes b after node a instead of all sibling nodes
description remarks
Select all descendant nodes b
(including only child nodes of node a , excluding grandchild nodes)
#$("a~b")
Note that it is after node a Sibling nodes,

3. Basic filter selector

Filter tags from the perspective of position.

##$("tagName:gt(2)")Select the elements after the third element in the tagName element set$("tagName:lt(2)")Select the third element in the tagName element set The element in front of the element $(":header") Select all title elements$(":animated")Select animated elements$("tagName:not(.one)")Select elements whose class value is not one in the tagName element set
express description remarks
$("tagName:first") Select the first element in the tagName element collection
$("tagName:last") Select the tagName element The last element in the collection
$("tagName:odd") Select the element at an odd position in the tagName element collection
$("tagName:even") Select the even-numbered element in the tagName element set
$("tagName:eq(1)") Select the second element in the tagName element collection
(The index is the same as the array, starting from zero)
(i.e. under tagName , elements with positions greater than 3)
(that is, the element under tagName with a position less than 3)
(h1 to h6)

4. Content filter selector

Whether the node value is empty, Whether the text on the node contains the specified string, and whether the class value in the child element is the specified value.

expressdescriptionremarks$("tagName:empty")Select elements with empty content in the tagName element collection$("tagName:parent")Select elements that contain child elements in the tagName element set$("tagName:contents('abc')")Select the element whose content contains "abc" in the tagName element set$("tagName:has(.one)")Select the class value in the tagNmae element set as element of one

5. Attribute filter (select elements containing specified attributes)

Filter nodes based on their attributes: with or without attributes, Attribute values ​​are equal to, not equal to, include, start with **, end with **, multiple filtering.

(Not a child element)
(Not a child element)
(not a child element, but a tagName element)
#expressdescriptionremarks$("div[id]")The selected element contains the id attribute##$("div[id='test']")$("div[title!='test']")$("div[title^='te']")$("div[title$='st']")$("div[title*='est']")$("div[title*='est'][id]")And has the id attribute
The selected element contains id="test"
The title attribute of the selected element is not "test"
The title attribute value of the selected element starts with "test"
The title attribute of the selected element ends with "test"
The title attribute value of the selected element contains "est"
The title attribute value of the selected element contains "est",

6. Visibility filter selector

Select nodes based on whether elements on the page are displayed

##expressdescriptionremarks$("div:hidden")Select the hidden div element$("div :hidden")Select all hidden elements in the div element$("div:visiable")Select visible div elements$("div :visiable") Select the visible elements in the div
(including child elements and grandchild elements)
(including child elements and grandchild elements)

The above is the detailed content of Introduction to JQuery's various selectors. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to delete Xiaohongshu notes How to delete Xiaohongshu notes Mar 21, 2024 pm 08:12 PM

How to delete Xiaohongshu notes? Notes can be edited in the Xiaohongshu APP. Most users don’t know how to delete Xiaohongshu notes. Next, the editor brings users pictures and texts on how to delete Xiaohongshu notes. Tutorial, interested users come and take a look! Xiaohongshu usage tutorial How to delete Xiaohongshu notes 1. First open the Xiaohongshu APP and enter the main page, select [Me] in the lower right corner to enter the special area; 2. Then in the My area, click on the note page shown in the picture below , select the note you want to delete; 3. Enter the note page, click [three dots] in the upper right corner; 4. Finally, the function bar will expand at the bottom, click [Delete] to complete.

What should I do if the notes I posted on Xiaohongshu are missing? What's the reason why the notes it just sent can't be found? What should I do if the notes I posted on Xiaohongshu are missing? What's the reason why the notes it just sent can't be found? Mar 21, 2024 pm 09:30 PM

As a Xiaohongshu user, we have all encountered the situation where published notes suddenly disappeared, which is undoubtedly confusing and worrying. In this case, what should we do? This article will focus on the topic of "What to do if the notes published by Xiaohongshu are missing" and give you a detailed answer. 1. What should I do if the notes published by Xiaohongshu are missing? First, don't panic. If you find that your notes are missing, staying calm is key and don't panic. This may be caused by platform system failure or operational errors. Checking release records is easy. Just open the Xiaohongshu App and click "Me" → "Publish" → "All Publications" to view your own publishing records. Here you can easily find previously published notes. 3.Repost. If found

How to add product links in notes in Xiaohongshu Tutorial on adding product links in notes in Xiaohongshu How to add product links in notes in Xiaohongshu Tutorial on adding product links in notes in Xiaohongshu Mar 12, 2024 am 10:40 AM

How to add product links in notes in Xiaohongshu? In the Xiaohongshu app, users can not only browse various contents but also shop, so there is a lot of content about shopping recommendations and good product sharing in this app. If If you are an expert on this app, you can also share some shopping experiences, find merchants for cooperation, add links in notes, etc. Many people are willing to use this app for shopping, because it is not only convenient, but also has many Experts will make some recommendations. You can browse interesting content and see if there are any clothing products that suit you. Let’s take a look at how to add product links to notes! How to add product links to Xiaohongshu Notes Open the app on the desktop of your mobile phone. Click on the app homepage

Let's learn how to input the root number in Word together Let's learn how to input the root number in Word together Mar 19, 2024 pm 08:52 PM

When editing text content in Word, you sometimes need to enter formula symbols. Some guys don’t know how to input the root number in Word, so Xiaomian asked me to share with my friends a tutorial on how to input the root number in Word. Hope it helps my friends. First, open the Word software on your computer, then open the file you want to edit, and move the cursor to the location where you need to insert the root sign, refer to the picture example below. 2. Select [Insert], and then select [Formula] in the symbol. As shown in the red circle in the picture below: 3. Then select [Insert New Formula] below. As shown in the red circle in the picture below: 4. Select [Radical Formula], and then select the appropriate root sign. As shown in the red circle in the picture below:

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Learn the main function in Go language from scratch Learn the main function in Go language from scratch Mar 27, 2024 pm 05:03 PM

Title: Learn the main function in Go language from scratch. As a simple and efficient programming language, Go language is favored by developers. In the Go language, the main function is an entry function, and every Go program must contain the main function as the entry point of the program. This article will introduce how to learn the main function in Go language from scratch and provide specific code examples. 1. First, we need to install the Go language development environment. You can go to the official website (https://golang.org

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to publish notes tutorial on Xiaohongshu? Can it block people by posting notes? How to publish notes tutorial on Xiaohongshu? Can it block people by posting notes? Mar 25, 2024 pm 03:20 PM

As a lifestyle sharing platform, Xiaohongshu covers notes in various fields such as food, travel, and beauty. Many users want to share their notes on Xiaohongshu but don’t know how to do it. In this article, we will detail the process of posting notes on Xiaohongshu and explore how to block specific users on the platform. 1. How to publish notes tutorial on Xiaohongshu? 1. Register and log in: First, you need to download the Xiaohongshu APP on your mobile phone and complete the registration and login. It is very important to complete your personal information in the personal center. By uploading your avatar, filling in your nickname and personal introduction, you can make it easier for other users to understand your information, and also help them pay better attention to your notes. 3. Select the publishing channel: At the bottom of the homepage, click the "Send Notes" button and select the channel you want to publish.

See all articles