jQuery selector filter

What is the selector
jQuery to mimic CSS selector syntax provides rules of grammar A method for easier access node to be operated.
A substantially selector
1 Css Selector
1) #id: ID selector, such as: Katex the parse error: the Expected 'the EOF', GOT '#' position AT. 3: ( '# D1') 2) .class: ... ( ' .s1 ')
. 3) Element: tag selector, such as: ( d i v ) 4 s e l e c t o r 1 , s e l e c t o r 2... s e l e c t o r n (& # X27; div & # x27;) 4) selector1, selector2 ... selectorn: group selector, such as: '# D1, P').
. 5): universal selector, such as: $ ( '')

2 level selector
1) descendant element selector select1 select2: all descendants (to meet the requirements of select2).
2) sub-element selectors select1> select2: consider only the child nodes (to meet the requirements select2's), grandson no matter ~
3) close sibling selectors select1 + select2: next sibling (to meet the requirements select2's), son no matter ~
4) adjacent sibling / sibling selectors select1 ~ select2: All of the following brothers (to meet the requirements of select2), regardless of the above brothers - brothers,
sons and regardless of ~

Form 3 domain selector
1): input: All form elements. 2): text: text box. 3): pasword: Password box.
4): radio: radio. 5): checkbox: multiple choice. 6): submit: Submit button.
7): image: the picture. 8): reset: reset button. 9): button: push button
NOTE: $ ( "input") tag selector to select all the input tag
$ ( ": input") form field selector to select all the elements form
two filter selector

4 basic filter selector / position
1): first: the first row.
2): last: the last line.
3): not (selector): meet the selector excluded. Remove all elements that match the given selected using the selector
4): even: even lines from the zero index. Selector matching the acquired element is an element index odd
5): odd: odd-numbered rows, index starts from 0. Matching the acquired selector element index value is an even element
6): eq (index): equal to the target element index from zero.
7): gt (index): the subject is greater than the element index from zero.
8): lt (index): less than the target element index from zero.
 Note: Before filters are no spaces. Is xx: first instead of xx: first.

Selector 5 content filter
1): contains (text): a matching element comprising a given text. $("div:contains(abc)")
2): empty: empty match all sub-elements or elements that do not contain text. $("div:empty")
3): has (selector): contains elements that match elements of the matching selector. $("div:has(p)")
4): parent: matching element comprises sub-elements, or text (opposite to empty).

Visibility filter selector 6
1): hidden match all invisible elements, or type of hidden elements.
2): visible matches all visible elements.

Attribute filter selector 7
1) [attribute]: the element has an attribute.
For example: $('div[id]').css('font-size','60px');// div id attribute has the element
2) [attribute = value]: the same value as the specified element value of a property.
For example: $('div[id=d1]').css('font-size','60px'); // is an element d1 ID of
3) [attribute = value!] : The specified value is not a property of the same elements.
For example: $('div[id!=d1]').css('font-size','60px'); // the above mentioned id is not an element d1

Filter subelements selector 8
1) :nth-child(index/even/odd): for each node of the sub-qualified for the same operation.
$("tr td:nth-child(2)").css("background-color", "blue");The first two color

9 form object attribute filter selectors
3): checked: radio button, checkbox options are selected.
For example: alert($(":radio:checked").val()); // the value output, similar to the value attribute
4): selected: drop-down list option is selected.
E.g:alert($("select option:selected").val())/alert($("select").val());

Guess you like

Origin blog.csdn.net/SqrsCbrOnly1/article/details/91378594