--jquery selector summary

$ ( "# MyELement") equal to the value of the element myElement select id, id, value can not be repeated in a document can have only one id value myElement So get is the only element

$ ( "Div") select all elements div tags, return the div element array

$ ( ". MyClass") choose to use css myClass class all the elements

$ ( "*") Select all elements in the document, you can use a variety of ways to select the joint selection: for example, $ ( "# myELement, div, .myclass")

Laminated selector:

$ ( "form input") to select all of the input element form elements
$ ( "# main> *" ) select all the main sub-element id value of
$ ( "label + input") to select all of the label elements an input element nodes, the test selector returns the label behind the label directly with all input label elements of an input tag of
$ ( "# prev ~ div" ) compatriots selector, the selector returned to the id tag element prev of All belong to the same parent div tag element

Basic filter selector:

$ ( "tr: first") to select the first all tr elements
$ ( "tr: last") select the last all tr elements
$ ( "input: not (:    checked) + span")

Filter out: checked selector of all input elements 

$ ( "tr: even") select all elements of the first tr ... 0,2,4 ... elements (note: if several elements selected because of an array, so the number is zero)  
$ ( "tr: odd") select all elements tr ... 1,3,5 ... elements
$ ( "td: eq (2 )") select all elements td td 2 of the serial number element
$ ( "td: gt (4)") to select all the td element td elements in a number greater than 4
$ ( "td: LL (4)") select all the td element td element number is less than 4
$ ( ": header ")
$ (" div: Animated ")

Content filter selector: 

$ ( "div: contains ( ' John')") div select all elements contained in the text of John
$ ( "td: empty") to select all of the array elements is empty td (not including text node)
$ ( " div: has (p) ") select all the elements contained p div tag
$ (" td: parent ") to select all of the parent node array element td

Filter visual selector: 

$ ( "div: hidden") select all of the hidden div element
$ ( "div: visible") to select all the visual elements of div

Attribute filter selectors:

$ ( "div [id]" ) select all div elements containing id attribute
$ ( "input [name = ' newsletter']") to select all of the name attribute is equal to 'newsletter' input element
$ ( "input [name! = 'newsletter'] ") to select all of the name attribute is not equal to 'newsletter' input element
$ (" input [name ^ = 'news'] ") to select all of the name attribute to 'news' input elements at the beginning
$ (" input [name $ = 'news'] ") to select all of the name attribute to 'news' end of the input element
$ (" input [name * = 'man'] ") to select all of the name attribute contains the 'news' input element
$ ( "input [id] [name $ = 'man']") may be combined using a plurality of attribute selection, which is obtained containing all of the id attribute and element properties that end with man

Filter subelements selectors:

$ ( "ul li: Nth-Child (2)"), $ ( "ul li: Nth-Child (the ODD)"), $ ( "ul li: Nth-Child (3N + 1)") 
  $ ( "div "array) returns all of the div element first child node-Child first: span
$ ( 'div span: last-Child") returns all div elements in the array of the last node
$ ( "div button: only- child ") returns an array of all the div only all child nodes of only one child node

Form elements Selector: 

$ ( ": Input") select all form input elements, including input, textarea, select and button 

$ ( ": text") to select all the text input elements
$ ( ": password") select all password input element
$ ( ": radio") select all radio input elements
$ ( ": checkbox") select all checkbox input elements
$ ( ": submit") select all submit input element
$ ( ": image") to select all of the image input elements
$ ( ": reset") to select all of the reset input elements
$ ( ": button") select all the button input element
$ ( ": file") to select all of the file input element
$ ( ": hidden") select all the input elements of type hidden or hidden form fields

Filter selector form elements: 

$ ( ": enabled") operable to select all of the form elements
$ ( ": disabled") Select All form elements inoperable
$ ( ": checked") are checked to select all of the form elements
$ ( "select option : selected ") selected sub-element of select all of the elements of being selected

The INPUT select a text box for the name "S_03_22" of a text value of td

?
1
$(”input[@ name =S_03_22]“).parent().prev().text()

Name with "S_" start, and not to "_R" at the end of

?
1
$(”input[@ name ^= 'S_' ]“).not(”[@ name $= '_R' ]“)

A value called the radio selected radio_01

?
1
$(”input[@ name =radio_01][@checked]“).val();

$ ( "A B") Find all child nodes A elements below, include non-direct child node
$ ( "A> B") to find the A element following direct child node
$ ( "A + B") to find the back of the element A brother node, including a non-direct child node
$ ( "a ~ B") a look behind the sibling elements, excluding non-direct child node

Guess you like

Origin www.cnblogs.com/jndx-ShawnXie/p/11798364.html