jquery acquires objects in a way that is sufficient to handle common types of objects _jquery

Source: Internet
Author: User
(1) Basic object acquisition

$("*")
Get all Objects

$ ("#element")
Obtaining an object with an ID of element is equivalent to document.getElementById ("element");

$ (". ABC")
To get an object with class ABC

$ ("div")
Get all the DIV elements in HTML

$ ("#a,. B,p")
Get ID A and Class B and all P elements

$ ("#a. B P")
Get the P element with ID A and Class B element

(2) Hierarchical object acquisition

$ ("Div>input")
Get all input objects under DIV

$ ("Div+h")
Gets the H element immediately following the DIV

$ ("div~p")
Gets all the P elements after the element div

(3) Simple Object acquisition

$ ("Element:first")
Gets the first instance of an element on the page ("Div:frist") to represent the first Div

$ ("Element:last")
Gets the last one of the elements on the page, such as $ ("Div:frist"), which represents the last Div

$ ("Element:not (selector)")
Remove all elements that match the selector such as $ ("Input:not (: Check)") to indicate all unchecked check boxes

$ ("Element:even")
Get even rows of element elements

$ ("element:odd")
Get odd rows of an element

$ ("Element:eq (Index)")
Getting the element of a particular index, such as $ ("Div:el (2)"), represents a third div

$ ("ELEMENT:GT (Index)")
Matches all elements that are greater than the given index value

$ ("Element:lt (Index)")
Matches all elements less than the given index

$ (": Header")
Elements that match H-tags

$ ("element:animated")
Matches all elements that do not have an animation effect

(4) Acquisition of content objects and visibility of objects

$ ("Element:contains (text)")
Whether the text in the element contains a letter or string

$ ("Element:empty")
To get an element object that does not contain text or child elements

$ ("element:parent")
Get object element contains text or child elements

$ ("Element:has (selector)")
Matches whether an element containing an element such as $ ("P:has (span)") represents all the P elements that contain span elements

$ ("Element:hidden")
Matches all invisible elements, including Display:none and the properties of input are hidden elements

$ ("element:visible")
Match all courseware elements

(5) object get Advanced

$ ("Element[id]")
Get all elements with an id attribute

$ ("ELEMENT[ATTRIBUTE=ABCD]")
Gets all elements of an ABCD attribute

$ ("ELEMENT[ATTRIBUTE!=ABCD]")
To get all elements that have a property that is not ABCD

$ ("Element[attribute^=ab]")
Get all the elements of a property that start with AB

$ ("Element[attribute$=ab]")
To get all the elements of a property ending in AB

$ ("Element[attribute*=ab]")
Get all the elements that contain a property containing AB

$ ("element[selector1][selector2][...]")
Conforming to a property selector such as $ ("INPUT[ID][NAME][VALUE=ABCD]") means that an INPUT element with ID, name, and value is ABCD is obtained

(6) Acquisition of child elements

$ ("Element:nth-child (Index)")
Select the nth child element under the parent and the index starts at 1
: Nth-child (even) even
: Nth-child (odd) odd
: Nth-child (3n) expression
: Nth-child (2) Index
: Nth-child (3n+1) expression

$ ("Element:first-child")
The first child element under the parent

$ ("Element:last-child")
The last child element under the parent

$ ("Element:only-child")
A unique child element under the parent

(7) Acquisition of form objects

$ (: Input)
can only match INPUT element type to input button select textarea

$ (: Text)
All When line text boxes

$ (:p assword)
All Password boxes

$ (: Radio)
All radio buttons

$ (: checkbox)
All check boxes

$ (: Submit)
All Submit Buttons

$ (: image)
All picture fields
$ (: RESET)
All recharge Buttons

$ (: button)
All buttons

$ (: File)
All file upload fields

$ (: Hidden)
All invisible elements or elements of type hidden

$ (: Enabled)
All available input elements

$ (:d isabled)
All unavailable input elements

$ (: Checked)
All check box elements

$ (: Selected)
All drop down tables

(8) the setting and removal of element attributes

$ ("Element"). attr (name)
Gets the property value of the first matching element, such as $ ("img"). attr ("src");

$ ("Element"). attr ({key:value,key:value,......})
Set multiple properties for one element at a one-time

$ ("Element"). attr (Key,value)
Set properties for an element

$ ("Element"). attr (Key,function)
Set a computed property for all matching elements

$ ("Element"). Removeattr (name)
Remove a property

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.