JQuery selector concise summary (including usage examples, clear at a glance)

Source: Internet
Author: User

This article now makes a summary of all the known jquery selectors. It is helpful for us to quickly write jquery! The following is a list of jquery's various options! Since jquery is very simple to use, I will not give examples to further understand it here.

Selector Instance Select
* $ ("# Item *") Select all the elements under item as the id attribute.
#Id $ ("# Lastname ") Id = "lastname" element
.Class $ (". Intro ") All class = "intro" Elements
Element $ ("P ") All <p> Elements
.Class.Class $ (". Intro. demo ") All class = "intro" and class = "demo" Elements
     
: First $ ("P: first ") First <p> element
: Last $ ("P: last ") Last <p> element
: Even $ ("Tr: even ") All even <tr> Elements
: Odd $ ("Tr: odd ") All odd <tr> Elements
: Next $ ('. Item'). next ('div ') Class is the next div sibling element of item, equivalent to $ ('. item + div ')
: Prev $ ('. Item'). prev ('div ') Class is the last div sibling element of item.
: NextAll $ ('. Item'). nextAll ('div ') Class is all div sibling elements after item, equivalent to $ ('. inside ~ Div ')
: Parent> child $ ('Div> span ') Select the first generation span element under the div, also known as the immediate child element
: Parent $ ('. Item: parent ') Select the parent element of the element whose class is item
     
: Eq (Index) $ ("Ul li: eq (3 )") The fourth element in the list (index starts from 0)
: Gt (No) $ ("Ul li: gt (3 )") List elements with an index greater than 3
: Lt (No) $ ("Ul li: lt (3 )") List elements whose index is less than 3
: Not (Selector) $ ("Input: not (: empty)") $ ("input: not (. must )") All input elements not empty; all elements whose class attributes are not must
     
: Header $ (": Header ") All title elements
: Animated   All animation Elements
     
: Contains (Text) $ ("Div: contains ('www .phpernote.com ')") All div elements include all elements of the www.phpernote.com string
: Empty $ (". Item: empty ") All elements of the element whose class attribute is item without child (element) nodes
: Hidden $ ("P: hidden ") All hidden <p> Elements
: Has $ ('. Item: has (span )') All the elements whose class attribute is item contain all the elements of span (whether or not they are directly in the System)
: Visible $ ("Table: visible ") All visible tables
     
S1, s2, s3 $ ("Th, td,. intro ") All elements with matching Selection
     
[Attribute] $ ("A [href]") All a tag elements with href attributes
[Attribute=Value] $ ("[Href = '#']") The value of all href attributes is equal to the "#" element.
[Attribute! =Value] $ ("[Href! = '#'] ") The values of all href attributes are not equal to "#" elements.
[Attribute$ =Value] $ ("Your href00000000'.jpg ']") The values of all href attributes contain elements ending with ". jpg ".
     
: Input $ (": Input ") All <input> Elements
: Text $ (": Text ") All <input> elements of type = "text"
: Password $ (": Password ") All <input> elements of type = "password"
: Radio $ (": Radio ") All <input> elements of type = "radio"
: Checkbox $ (": Checkbox ") All <input> elements of type = "checkbox"
: Submit $ (": Submit ") All <input> elements of type = "submit"
: Reset $ (": Reset ") All <input> elements of type = "reset"
: Button $ (": Button ") All <input> elements of type = "button"
: Image $ (": Image ") All <input> elements of type = "image"
: File $ (": File ") All <input> elements of type = "file"
     
: Enabled $ (": Enabled ") All activated input Elements
: Disabled $ (": Disabled ") All disabled input Elements
: Selected $ (": Selected ") All selected input Elements
: Checked $ (": Checked ") All selected input Elements

Related Article

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.