Show Menu
Cheatography

Jquery Bruce Cheat Sheet by

Basic Selectors

*
All Elements (including head)
#ID
Element of specified ID
.classname
Elements of classname
tagname
Elements of tagname
a[href]
Anchor with href attribute
a[href­='v­alue']
Anchor with href = 'value'
a[href­|='­value']
Anchor with href = 'value'
or
href starting with 'value-'
a[href­^='­value']
Anchor with href beginning with 'value'
a[href­!='­value']
Anchor with href not equal to value
a[href­$='­value']
Anchor with href ending with 'value'
a[href­*='­value']
Anchor with href containing 'value'
a[href­~='­value']
Anchor with href = 'value'
or
href containing complete word 'value'
a[C1][C2]
Anchor with attributes satisfying criteria C1 and C2
s1s2
Elements satisfying
selector1 and selector2
s1,s2
Elements satisfying
selector1 or selector2
s1>s2
Elements satisfying
selector2
and
direct child of selector1
s1 s2
Elements satisfying
selector2
and
descen­dants of selector1
s1+s2
Elements satisfying
selector2
and
next immediate sibiling of selector1
s1~s2
Elements satisfying
selector2
and
next sibiling of selector1

Form Filters

:button
<bu­tto­n>
<input type = submit, reset or button>
:checkbox
:checked
checked or selected state
:selected
selected option of <se­lec­t>
:disabled
:enabled
:file
<input type="f­ile­">
:focus
:image
<intput type="i­mag­e">
:input
<in­put>
<select>
<textarea>
<button>
:password
<input type="p­ass­wor­d">
:radio
:reset
:submit
:text
<input type="t­ext­">

Attributes and Properties

$(A).a­ttr­(name)
get specified attribute value (in string) for first element in $(A)
$(A).attr(name,value|Function)
$(A).attr({name:value|Function,etc}}
set specified attribute for all elements in $(A)
$(A).r­emo­veA­ttr­(name)
$(A).p­rop­(name)
get specified attribute value for first element in $(A)
$(A).prop(name,value|Function)
$(A).attr({name:value|Function,etc}}
$(A).r­emo­veP­rop­(name)
$(A).d­ata­(na­me,­value)
Store name=value pair in jQuery memory cache
if name is my-love, it is stored as myLove
$(A).d­ata­([n­ame])
Get name value from jQuery Cache else data-name attribute
$(A).removeData([name])
$.removeData(js elemen­t,[­name])
$.hasD­ata(js element)
Check if element has any associated data in jqeury cache
 

Position Filters

:first
:last
:eq(n)
nth element (0-based index)
:lt(n)
:gt(n)
elements before­/after nth index
:even
:odd
elements at even /odd index
:first-child
:last-child
nth-child(n)
nth-child(even|odd)
nth-child(Xn+Y)
nth child (1-based index)
nth-last-child(n)
nth-last-child(even|odd)
nth-last-child(Xn+Y)
nth child, starting from the last
nth-of-type(n)
nth-of-type(even|odd)
nth-of-type(Xn+Y)
nth-last-of-type(n)
nth-last-of-type(even|odd)
nth-last-of-type(Xn+Y)
:only-­child
elements with no sibilings
:only-­of-type
elements with no sibilings of same type

Content Filters

:conta­ins­(text)
elements containing text
:empty
:has(s­ele­ctor)
elements containing at least one selector
:parent
elements with at least one child node

Other Filters

:animated
elements currently under animated control
:header
<h1> through <h6>
:visible
:hidden
:lang(­lan­guage)
:not(s­ele­ctor)
:root
element which is root of the document
:target
element targeted by the document's URI's identifier
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Web Programming Cheat Sheet
          jQuery Cheat Sheet
          jQuery Mobile Cheat Sheet