Selector Reference

Next ❯Traversing Reference

Selectors are being used to select elements, you want to do some action on it

SelectorsUsed
*To select all elements
elementTo select specific type of elements
thisTo select current element, only used inside events
#idNameTo select element with a specific 'id' name
.classNameTo select all elements with a specific 'class' name
.className.classNameNTo select all elements with a specific 'multiclass' names
element, elementTo select all specific group of elements
documentTo select the document, only used with events
windowTo select the window, only used with events

descendant selector [space]To select all specific child, grand-child, grand-grandchild and so on, of a specified element
child selector [>]To select all specific direct child of a specified element
adjacent sibling selector [+]To select all elements that are placed immediately after a specified element
general sibling selector [~]To select all elements that are siblings (sharing same parent) of a specified element

[attribute]To select all elements having specified attribute
[attribute="value"]To select all elements having specified attribute with specified value
[attribute!="value"]To select all elements not having specified attribute with specified value
[attribute|="value"]To select all elements having specified attribute with specified value equal to or followed by a hyphen(-)
[attribute~="value"]To select all elements having specified attribute containing a specified value
[attribute^="value"]To select all elements having specified attribute begins with specified value
[attribute$="value"]To select all elements having specified attribute ends with specified value
[attribute*="value"]To select all elements having specified attribute which contains substring as specified value

:animatedTo select currently animated element (animation only via animate() function)
:buttonTo select input elements with type="button"
:checkboxTo select input elements with type="checkbox"
:checkedTo select checked input element
:disabledTo select disabled element
:emptyTo select element that has no children & no text
:enabledTo select enabled element
:evenTo select even index element
:fileTo select input elements with type="file"
:firstTo select the first element
:focusTo select input element that has focus
:headerTo select only the header(<h1> - <h6>) element
:hiddenTo select the hidden element
:imageTo select input elements with type="image"
:inputTo select input elements
:lastTo select the last element
:oddTo select odd index element
:parentTo select element that have at least one child (either an element or text)
:passwordTo select input elements with type="password"
:radioTo select input elements with type="radio"
:resetTo select input elements with type="reset"
:rootTo select the document's root element
:submitTo select input elements with type="submit"
:textTo select input elements with type="text"
:visibleTo select the visible element

:contains(text)To select element containing specific text
:eq(index)To select sepcific index element
:gt(index)To select elements with value greater then specific index
:has(sp_selector)To select element having specific-selector as child
:lang(language)To select element with a "lang" attribute with specified value
:lt(index)To select elements with value lesser then specific index
:not(sp_selector)To select element which is not having specific-selector

:first-childTo select element that are the first child of its parent
:first-of-typeTo select element that are the first of its type, of its parent
:last-childTo select element that are the last child of its parent
:last-of-typeTo select element that are the last of its type, of its parent
:only-childTo select element that are the only child of its parent
:only-of-typeTo select element that are the only child of its type, of its parent
:nth-child(n)To select element that are the nth child of its parent
:nth-of-type(n)To select element that are the nth child of its type, of its parent
:nth-last-child(n)To select element that are the nth child of its parent from last
:nth-last-of-type(n)To select element that are the nth child of its type, of its parent from last

  • Traversing Reference
❮ Prev Extra Methods
Next ❯Traversing Reference
TryOut Examples"Learn to Explore..!"

TryOut Editor

receipt