JQuery selector concise summary (including usage examples, at a Glance) _ jquery-js tutorial

Source: Internet
Author: User
JQuery selector has always been the most mysterious and powerful part of jquery. Of course, it is also a very basic part of jquery. This article summarizes all the known jquery selector, having a deep understanding of these selectors 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.

Element Element
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

Element

.Class.Class $ (". Intro. demo ") All class = "intro" and class = "demo" Elements
: First $ ("P: first ") First

Element

: Last $ ("P: last ") Last

Element

: Even $ ("Tr: even ") All even numbers
: Odd $ ("Tr: odd ") All odd
: Next $ ('. Item'). next ('P ') Class is the next p sibling element of item, equivalent to $ ('. item + p ')
: Prev $ ('. Item'). prev ('P ') Class is the last p sibling element of item.
: NextAll $ ('. Item'). nextAll ('P ') Class is all p sibling elements after item, equivalent to $ ('. inside ~ P ')
: Parent> child $ ('P> span ') Select the first generation span element under p, 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) $ ("P: contains ('www .phpernote.com ')") All p 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

Element

: 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 ") AllElement
: Text $ (": Text ") All types = "text"Element
: Password $ (": Password ") All types = "password"Element
: Radio $ (": Radio ") All types = "radio"Element
: Checkbox $ (": Checkbox ") All types = "checkbox"Element
: Submit $ (": Submit ") All types = "submit"Element
: Reset $ (": Reset ") All types = "reset"Element
: Button $ (": Button ") All types = "button"Element
: Image $ (": Image ") All types = "image"Element
: File $ (": File ") All types = "file"Element
: 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.