Show Menu
Cheatography

jQuery Cheat Sheet (DRAFT) by

A reference for jQuery (currently version 1.10) including selectors, functions, element manipulation and more.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

jQuery Links and Info

jQuery Homepage
jQuery Docume­ntation
This cheat sheet based on, and intended to provide a printable version of, the excellent jQuery cheat sheet by @misteroom
Cheat sheet based on jQuery 1.10.

jQuery Selectors: Basic

Selector
Description
Matches all elements
Elements of type "­ele­men­t"
Elements with class "­cla­ss"
Element with id "­id"
Use commas to separate selectors

jQuery Selectors: Hierarchy

Selector
Descri­ption
Match any child which is directly within parent
Match any descendant contained within ancestor
Match next where it follows prev
Match all siblings where following prev

jQuery Selectors: Basic Filters

Selector
Descri­ption
Has animation in progress
At position "­n" in set
Even elements in set
First element in set
After position "­n" in set
All headers (h1, h2 etc)
Has lang attribute set to "­x"
Last element in set
Before position "­n" in set
In set not matching selector "­x"
Odd elements in set
Document root
Has ID equal to URL fragment

jQuery Selectors: Content Filters

Selector
Descri­ption
Elements containing text "­x"
Elements with no children
Elements containing elements matching selector "­x"
Elements with at least one child

jQuery Selectors: Visibility Filters

Selector
Description
Hidden elements
Visible elements

jQuery Selectors: Attributes

Selector
Descri­ption
Has attribute "­nam­e"
Where "­nam­e" equals "­val­"
Where "­nam­e" equals "­val­" or starts "­val­-"
Where "­nam­e" contains "­val­"
Where "­nam­e" contains "­val­" as a word
Where "­nam­e" starts with "­val­"
Where "­nam­e" ends with "­val­"
Missing attribute "­nam­e", or "­nam­e" does not equal "­val­"

jQuery Selectors: Child Filters

Selector
Descri­ption
Elements which are the first child of their parent
Elements which are, of their element type, the first child
Last child of their parent
Of their element type, the last child
Elements which are the nth child of their parent
As :nth-c­hild, but counting from last element in set backwards
As nth child, but matching by element
As :nth-o­f-type, but counting from last element in set backwards
Elements which are only child of their parent
Elements which are only child, of their element type, of their parent
1 These selectors are 1-indexed, not 0-indexed

jQuery Selectors: Forms

Selector
Description
Button elements
Checkbox elements
Checked elements
Disabled elements
Enabled elements
Elements with focus
File elements
Image elements
Input, textarea, select or button
Password elements
Radio elements
Reset elements
Selected elements
Submit elements
Text elements