Home > Web Front-end > JS Tutorial > body text

jQuery selector gets all parent elements and below elements at once

php中世界最好的语言
Release: 2018-03-15 10:15:47
Original
1438 people have browsed it

This time I will bring you jQueryThe selector obtains all parent elements and the following elements at one time, and the jQuery selector obtains all the parent elements and the following elements at one timeNotesWhat are they? Here are actual cases. Let’s take a look.

1. Get the parent element

$("#id").parent()

Get its parent Level element

$("#id").parents()

Get all its ancestor elements

$("# id").closest()

Get its nearest ancestor element and trace back in sequence

------------------- -------------------------------------------------- -----------

2. Get sibling elements

$("#id").next (selector)

Get the next sibling element immediately next to the matching element. If a selector is provided, retrieves the next sibling element that matches the selector.

$("#id").nextAll(selector)

Get all sibling elements after the matching element. Filtering by the selector is optional.

$("#id").prev(selector)

Get the immediately preceding sibling element of the matched element (opposite to next)

$("#id").prevAll(selector)

Get all sibling elements before the current matching element (opposite to nextAll)

-------------------------------------------------- ----------------------------------

3. Get child elements

$("#id").children(selector)

Returns the child elements of the matching element. Add optional parameters to filter through the selector.

$("#id").find(selector)

Get the descendants of the current element

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!

Recommended reading:

Request ajax in jquery and response ajax in servlet

Implement jquery on the startup page Load data immediately

Realize the linkage effect between the input box and the drop-down box

How to achieve dynamic acquisition of Jquery drop-down box data

The above is the detailed content of jQuery selector gets all parent elements and below elements at once. 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 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!