The razor-sharp jquery Learning notes jquery Selector

Source: Internet
Author: User

The jquery selector is divided into: basic selector, hierarchy selector, filter selector and form selector.

1. Basic Selector

The basic selector is the most commonly used selector in jquery and the simplest selector.

2. Hierarchy Selector

Hierarchical selectors are a good choice if you want to get specific elements, such as descendant elements, child elements, neighboring elements, and sibling elements, through hierarchical relationships between the DOM.

In the hierarchy selector, the first and second choices are common, and the next two in jquery can be replaced in a simpler way, so the chances of using them are relatively small.

3. Filter Selector

The filter selector primarily filters out the required DOM elements through a specific filtering rule, which is the same as the pseudo-class selector syntax in CSS, where the selector begins with a colon (:). According to different filtering rules, filter selectors can be divided into basic filtering, content filtering, visibility filtering, attribute filtering, sub-element filtering and Form object property filter selectors.

3.1. Basic Filter Selector

3.2. Content Filter Selector

The filtering rules of the Content filter selector are mainly embodied in the sub-elements or text content that it contains.

3.3. Visibility Filter Selector

The visibility selector selects the appropriate element based on the visible and invisible state of the element.

In the visibility selector, you need to be aware of the selector: hidden, which not only includes elements that have the Style property display as "None", but also elements such as text-hidden fields (<input type= "hidden" >) and Visibility:hidden.

3.4. Attribute Filter Selector

The filter rule for a property filter selector is to get the corresponding element through the attributes of the element.

3.5. Child element Filter Selector

Filter rules for child element filter selectors be aware of the distinction between the parent and child elements of an element.

3.6. Form object property Filter Selector

The Form object property filter Selector mainly filters the selected form elements, such as selecting the Selected drop-down box, multi-box, and so on.

4. Form Selector

In order to be able to operate the form more flexibly, jquery has specifically added a form selector, which allows it to easily get to one or more elements of the form.

The razor-sharp jquery Learning notes jquery Selector

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.