jquery application - find element correlation (selector);

Child element selector:

    //  Big premise: all the selected ones are used to decorate Div. is div the first child of its parent element (without limitation)? Is it the last child? Is it the index child? Is it the only child?
    $('div:first-child') // Match all div s that are the first element
    $('div:last-child') // Match all div s for the last element
    $('div:nth-child(index)') // Match all div s with index
    $('div:only-child') // Match all div s that are unique children of the parent element
    // 1.9+
    // Big premise div: first of type is a whole, and the final result is that the first element of the parent element (DIV) is div, and the last element;
    $('div:first-of-type') // Match all divs that are the first element in a div
    $('div:last-of-type') // Match all divs that are the last element in a div
    $('div:nth-of-type(index)') // Match all div elements with index value in div

Obfuscation selector:

When the class selector or ID selector contains some CSS special characters;

Basic selector:

$('*')

$( '#id')

$('.class')

$('element')  // div p span ...

Level selector:

$('parent children') // All child elements of parent;
$('parent > children') // parent direct child element;
$('prev + next') // All next elements after prev;
$('prev ~ siblings') // Match all sibling elements of siblinks;

Property selector:

$('div[attr]') // Select all div with attribute attr
$('div[attr = value]') // Select all div s with attr = value attribute
$('div[attr != value]') // Select all div s with attribute attr and attr is not value
$('div[attr ^= value]') // Select all div whose value of attr starts with value
$('div[attr $= value]') // Select the div whose value ends with value for all attr values
$('div[attr *= value]') // Select all div whose attr value contains value
$('div[attr][attr1][attr2='value']') // Select all div s that have and meet the conditions

Basic filter:

  
    $('div:first') // The first div in the selected jquery element group
    $('div:last') // The last div in the selected jquery element group
    $('div:not(selector)') // Remove the objects in the selected jquery object group that meet the selector condition;
    $('div:even');$('div:odd') // Match all elements whose index value is even / cardinality;
    $('div:eq(index)') // Match the element whose index value is index;
    $('div:gt(index)') // Match all elements whose index value is greater than index;
    $('div:lt(index)') // Match all elements whose index value is less than index;
    $(':header')  // Match all header(h1-h6) elements;
    $(':animated')  // Match all moving elements;
    $(':focus') // Match the currently focused element;
    // 1.9+
    $('div:lang(language)') // Match the language code provided by a language value;
    $(':root') // Document root directory; html element;
    $(':target') // http://jquery.cuishifeng.cn/target.html

Content selector:

    $('div:contains(text)') // Match the element containing the given text;
    $('div:has(selector)') // Match the element containing the given element;
    $('div:empty') // Match the empty element contained;
    $('div:parent') // Match all elements that have children or text; all elements that have content; 
    // < div class = "demo" > div < / div > demo satisfied
    // < div class = "demo" >

Visibility selector:

    $('div:visible') // Match all visible elements
    $('div:hidden') // Match all invisible elements, or type value (first element must have type) is hidden

Form element selector:

: input matches all input elements;

: Text: Password: Radio: checkbox: submit: Image: reset: button file matches all elements of type text, password, radio, checkbox, submit, image, reset, button, file;

Form object property selector:

: enabled operable

: disabled inoperable

: checked selected

: selected

Keywords: JQuery Attribute less

Added by johnnyboy16 on Mon, 30 Dec 2019 19:38:35 +0200