javascript--Selector

Source: Internet
Author: User

1, the selector is the foundation of jquery, in jquery, the event processing, traversal DOM and AJAX operations are dependent on the selector.

2, the advantages of choice:

--concise wording;

--perfect event handling mechanism.

3. Basic selector:

--The basic selector is the most commonly used selector in jquery and the simplest selector, which finds DOM elements through element Id,class and tag names (only once in a Web page, and class allows for reuse);

4. Hierarchy selector:

-If you want to get specific elements through hierarchical relationships between DOM, such as descendant elements, child elements, neighboring elements, sibling elements, etc., you need to use a hierarchy selector;

The--$ ("prev ~ div") selector can select only the sibling elements that follow the "#prev" element, whereas the method siblings () in jquery is independent of the position, as long as it is a sibling node;

5. Filter selector:

--The filter selector primarily filters out the required DOM elements through a specific filtering rule, which begins with ":";

Filter selectors can be divided into basic filtering, content filtering, visibility filtering, attribute filtering, sub-element filtering and Form object attribute filter selectors according to different filtering rules;

--1) Basic Filter Selector:

--2) Content Filter Selector: The filtering rules of content filter selectors are mainly embodied in the sub-elements and text content;

--3) Visibility Filter selector: Selects the appropriate element based on the visible and invisible state of the element;

--Visible Selector: The hidden contains not only elements of the style property display as none, but also elements such as the text-hiding field (<input type= "hidden"/>) and Visible:hidden;

--4) Property Filter selector: Gets the corresponding element by its attributes

--5) child element filter selector:

The--nth-child () selector is detailed below:

--①:nth-child (even/odd): The element that can select the index value under each parent element is even (odd) number;

--②:nth-child (2): You can select an element with an index value of 2 under each parent element;

--③:nth-child (3n): can select the element under each parent element that the index value is a multiple of 3;

--④:nth-child (3n+1): can select each parent element under the index value is 3n+1 element;

--6) Form object property Filter Selector: This selector primarily filters the selected form:

--7) Form selector:

javascript--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.