1. Some core JQuery Methods
Each (callback) 'is like a loop
$ ("Element"). length; 'number of elements, which is an attribute
$ ("Element"). size (); 'is also the number of elements, but parentheses are a method.
$ ("Element"). get (); 'a collection of elements on the page, stored in Arrays
$ ("Element"). get (index); 'is the same as above. index indicates the elements and subscript of the array.
$ ("Element"). get (). reverse (); 'indicates the direction of the obtained array.
$ ("Element1"). index ($ ("Element2"); 'the index value of element 2 in element 1 is.
2. Get basic objects (note that Jquery objects instead of Dom objects are obtained here, but they can be converted)
$ ("*") 'Indicates getting all objects, but I have never used it like this.
$ ("# XXX") 'obtain the Element Object id = XXX (id can be the tag id or CSS style id)
$ ("Input [name = 'username']") obtain the Element Object name = 'username' in the input tag.
$ (". Abc") 'to obtain the style class name is. abc element object commonly used
$ ("Div") 'tag selector Selects all div elements commonly used
$ ("# A,. B, span") 'indicates the element whose ID is a, the element that uses Class B, and all span elements.
$ ("# A. B p") 'id is a and all p elements in the B style are used.
3. Hierarchical Element Acquisition
$("Element1 Element2 Element3...") 'the front parent level is followed by a subset
$ ("Div> p") 'gets all p elements under the div.
$ ("Div + p") the first p element after the div Element
$ ("Div ~ P ") All p elements behind 'div
4. Simple Object acquisition
$ ("Element: first") 'First Element of a certain Element in the HTML page
$ ("Element: last") the last Element of a certain Element in the HTML page
$ ("Element: not (selector)") 'removes all elements that match the given selector, for example: $ ("input: not (: checked )") indicates Selecting All unselected check boxes.
$ ("Element: even") 'returns an even number of rows.
$ ("Element: odd") 'returns an odd number of rows.
$ ("Element: eq (index)") 'gets a given index value
$ ("Element: gt (index)") All elements after obtaining the Element of the given index value
$ ("Element: lt (index)") 'gets all elements before the Element of the given index value
5. Get content objects and object visibility
$ ("Element: contains (text)") 'indicates whether the Element contains text content.
$ ('Element: empty ") 'gets
$ ("Element: partnt") 'obtains
$ ("Element: has (selector)") 'indicates whether an Element exists. For example, $ ("p: has (span)") indicates all p elements containing the span Element.
$ ("Element: hidden") 'select all visible elements
$ ("Element: visible") 'select all invisible elements
6. Other Object acquisition methods
$ ("Element [id]") 'all elements with the ID attribute
$ ("Element [attribute = youlika]" 'obtains all elements whose attributes are youlika.
$ ("Element [attribute! = Youlika] "'Get all elements whose property is not youlika
$ ("Element [attribute ^ = youlika]" 'obtains all elements whose attributes start with not youlika.
$ ("Element [attribute $ = youlika]" 'obtains all elements whose attributes are not the end of youlika.
$ ("Element [attribute * = youlika]" 'obtains all elements whose attributes start with youlika.
$ ("Element [selector1] [selector2] [...] ") 'matches the property selector. For example, $ (" input [id] [name] [value = youlika] ") indicates that the input element with ID, Name, and value is youlika is obtained.
7. Obtain sub-elements
$ ("Element: nth-child (index)") 'select the nth Element under the parent level
$ ("Element: nth-child (even)") 'select an even number under the parent level
$ ("Element: nth-child (odd)") 'select the odd number under the parent level
$ ("Element: nth-child (3n + 1)") 'expression
$ ("Element: first-child") 'selects the first child Element under the parent level.
$ ("Element: last-child") 'selects the last child Element under the parent level.
$ ("Element: only-child") 'matches a unique child Element under the parent level. For example, if dt is unique in the dl list, dt is selected.
8. Get form objects
$ (: Input) // query all Input elements, including the drop-down list, text field, single-statement, and check box.
$ (: Text) // match all single-row text boxes
$ (: Password) // match all password boxes
$ (: Radio) // match all radio buttons
$ (: Checkbox) // match all check boxes
$ (: Submit) // match all the submit buttons
$ (: Image) // match all image domains, such
$ (: Reset) // match all reset buttons
$ (: Button) // match all buttons
$ (: File) // match all file upload Domains
$ (: Hidden) // matches all the invisible elements or elements whose type is hidden.
$ (: Enabled) // match all available input elements. For example, radio: enabled indicates matching all available single-choice buttons.
$ (: Disabled) // matches all the unavailable input elements, which act in the opposite way.
$ (: Checked) // match all checked check box Elements
$ (: Selected) // match all the drop-down lists
9. Setting and removing element attributes
$ ("Element"). attr (name) 'gets the first matching property value, for example, $ ("img"). attr ("src ")
$ ("Element". attr (key, value) ") 'specifies the attribute of an Element.
$ ("Element". attr ({key: value, key1: value,...}) 'sets multiple attributes for an Element at a time.
$ ("Element"). attr (key, function) 'sets a calculated attribute value for all matching elements.
$ ("Element"). removeAttr (name) // remove an attribute