The three---jquery selector for front-end learning

Source: Internet
Author: User

the selectors in Jquery fall into several categories: basic filter selector, hierarchy selector, Content filter selector, visibility filter selector, attribute filter selector, child element filter selector, form object selector and form object Zodiac filter selector.

1. Non-basic filter selectors, generally need to use with the basic filter selector.

2, from the performance of the original Soundtrack support ID selector, tag Selector, class selector performance is best, the other is generally through the DOM Loop lookup to get, therefore, allow the condition, the first Choice JS native support JS native selector.

3, it is best to provide the context of the selector to narrow the target element's lookup range.

First, the basic selector.

#id;. Class;element;*;selector1,selector2,... Selectorn (the elements that match each selector are merged and returned together)

Second, level selector

$ ("ancestor descendant"); select descendant elements;

$ ("Parent>child"); Select child elements;

$ ("selector"). Next (); Select the next sibling element immediately following it;

$ ("selector"). Nextall () all sibling elements after the selection;

$ ("selector"). Siblings () selects all sibling elements before and after;

$ ("selector"). Prev () Gets the previous sibling element

$ ("selector"). Parents () gets the ancestor element

$ ("selector"). Parent () gets the parents element

$ ("selector"). Closet () Gets the most recent matching ancestor element

After several levels of lookup functions, you can use selectors as function parameters

Three, basic filter selectors

: First;:last;:even;:o Dd;:eq (index);: GT (index);: LT (index); Select according to the subscript of the same class of elements

: Not (selector);: Header;:animated;:focus::p arent; Select according to the state of the element

Iv. Content Filter Selector

: Empty;:contains (key);

: Has (Seletor) elements that conform to a selector feature

: Find (Seletor) a descendant element that conforms to a selector feature

: Filter (Seltor) a sibling element that conforms to a selector feature

V: Visibility Filter Selector

: hidden;:visible

Vi. Attribute Filter Selector

[attribute]; [Attribute=value]; [Attribute!=value]; [Attribute^=value]; [Attribute$=value]; [Attribute*=value]; [Attribute|=value]; [Attribute~=value]; [Attribute1] [Attribute2] ... [Attributen]

Seven: child element filter Selector

: Nth-child (index/even/odd);: First-child;last-child;:o Nly-child;

Eight: Form element selector

: Input;:text;:p assword;:radio;:checkbox;:submit;:image;:reset;:button;:file;

IX: Form element attribute filter Selector

: Enabled;:d isabled;:checked;:selected;

The three---jquery selector for front-end learning

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.