Selector are used to select elements and it is pretty difficult to remember about each and every selector. It would be nice, if all the selectors are placed together So they can referred quickly. I have prepared a list of mostly used selector.
Simple tag, class, and id selectors
*
tagname
.classname
#id
Selector combinations
A B B as a descendant of A
A > B B as a child of A
A + B B as a sibling following A
A ~ B B as a sibling of A
Attribute filters
[attr] has attribute
[attr=val] has attribute with value val
[attr!=val] does not have attribute with value val
[attr^=val] attribute begins with val
[attr$=val] attribute ends with val
[attr*=val] attribute includes val
[attr~=val] attribute includes val as a word
[attr|=val] attribute begins with val and optional hyphen
Element type filters
:button
:header
:password
:submit
:checkbox
:image
:radio
:text
:file
:input
:reset
Element state filters
:animated
:disabled
:hidden
:visible
:checked
:enabled
:selected
Selection position filters
:eq(n)
:first
:last
:nth(n)
:even
:odd
:gt(n)
:lt(n)
Document position filters
:first-child
:last-child
:only-child
:nth-child(xn+y)
:nth-child(n)
:nth-child(even)
:nth-child(odd)
Miscellaneous filters
:contains(text)
:not(selector)
:empty
:parent
:has(selector)
Feel free to contact me for any help related to jQuery, I will gladly help you.
Simple tag, class, and id selectors
*
tagname
.classname
#id
Selector combinations
A B B as a descendant of A
A > B B as a child of A
A + B B as a sibling following A
A ~ B B as a sibling of A
Attribute filters
[attr] has attribute
[attr=val] has attribute with value val
[attr!=val] does not have attribute with value val
[attr^=val] attribute begins with val
[attr$=val] attribute ends with val
[attr*=val] attribute includes val
[attr~=val] attribute includes val as a word
[attr|=val] attribute begins with val and optional hyphen
Element type filters
:button
:header
:password
:submit
:checkbox
:image
:radio
:text
:file
:input
:reset
Element state filters
:animated
:disabled
:hidden
:visible
:checked
:enabled
:selected
Selection position filters
:eq(n)
:first
:last
:nth(n)
:even
:odd
:gt(n)
:lt(n)
Document position filters
:first-child
:last-child
:only-child
:nth-child(xn+y)
:nth-child(n)
:nth-child(even)
:nth-child(odd)
Miscellaneous filters
:contains(text)
:not(selector)
:empty
:parent
:has(selector)
Feel free to contact me for any help related to jQuery, I will gladly help you.
No comments:
Post a Comment