Basic selector:
ID Selector: $ ("#id")
Tag Selector: $ ("tag")
Class Selector: $ (". ClassName")
Wildcard selector: $ ("*")
Group selector: $ ("Selector1,selector2,..., Selectorn")
Hierarchy selector:
Include selector: $ ("ancestor descendant")
Child selector: $ ("Parent>child")
Adjacent selector: $ ("Prev+next")
Brother Selector: $ ("Prev~siblingsa")
Simple pseudo-Class selector:
: The first example: $ ("P:first")//Match the number one P element
: Last Example: $ ("p:last")//Match final P element
: EQ (Index) Example: $ ("P:eq (1)")//Match P element with index value 1
Index starts from 0.
: even example: $ ("H1:even")//Match all H1 elements with an even number of index values
: odd Example: $ ("h1:odd")//Match all index values to an odd H1 element
: GT (Index) Example: $ ("H1:GT (1)")//Match all H1 elements with index values greater than 1 (1 not included)
: LT (Index) Example: $ ("H1:lt (2)")//Match all H1 elements with index values less than 2 (2 not included)
: Not (Selecor) Example: $ ("P:not (P:eq (1)")///Match index not 1 P element
: Animated//Match animated elements
: Header//Match header element
Pseudo-class selectors related to content:
: contains example: $ ("P:contains (' test1 ')")//Match P element containing test1 text
: empty Example: $ ("div:empty")//Match div element that does not contain child elements or text
: has example: $ ("Div:has (P)")//Match div element containing P element
:p Arent Example: $ ("div:parent")//Match a DIV element that contains child elements or text
Pseudo-class selectors related to element display states:
: hidden Example: $ (Div:hidden)//Match all the invisible div elements
: visible Example: $ (div:visible)//Match all visible div elements
pseudo-class selectors that match child elements :
: Nth-child matches nth child or odd-even element under its parent element (Nth-child: Starting from 1)
Example: $ (": Nth-child (even)")//number of spouse elements
$ (": Nth-child (Odd)")//match odd digit element
$ (": Nth-child (3n)")
$ (": Nth-child (2)")
$ (": Nth-child (3n+1)")
$ (": Nth-child (3n+2)")
: first-child Example: $ ("p:first-child")//Match each P element that belongs to the first child element of its parent element
: last-child Example: $ ("p:last-child")//Match each P element that belongs to the last child element of its parent element
: only-child Example: $ ("p:only-child")//match such a P element, his parent element contains only one element of his
Pseudo-classes related to form objects:
: input//matches all input, textarea, select, Button objects
: text//Match single line TextBox
:p Assword//Match all password boxes
: Radio//Match all radio buttons
: checkbox//Match all check boxes
: Submit//Match all submit buttons
: Reset//matches all reset buttons
: Image//Match all image fields
: Button//Match all buttons
: File//Match all Files fields
: Hidden//Match all invisible elements
Pseudo-class selectors related to form properties
: Enable
:d isable
: Checked//matches all selected elements (not including option)
: Selected//matches all selected option elements
Property selector:
[attribute]//Match all elements containing a given attribute
Example: $ ("p[id]")//Match P element containing id attribute
[Attribute=value]//Match attribute equals specific value element
[Attribute!=value]//Match attribute not equal to a specific value element
[Attribute^=value]//The element that matches a property value starting with some value
[Attribute$=value]//Match an element with an attribute value ending with some value
[Attribute*=value]//Match attribute value contains elements of certain values
[Selector1] [Selector2] [Selectorn]//match elements that meet all matching criteria