Catalog / jQuery Cheatsheet
jQuery Cheatsheet
A quick reference guide to jQuery, covering selectors, DOM manipulation, events, effects, and AJAX.
Selectors
Basic Selectors
|
Selects all elements. |
|
Selects the current HTML element. |
|
Selects all |
|
Selects all elements with class=“example”. |
|
Selects the element with id=“firstname”. |
Attribute Selectors
|
Selects all elements with a |
|
Selects all elements with |
|
Selects all elements with |
|
Selects all elements with |
|
Selects all elements with |
Hierarchy Selectors
|
Selects all elements that are descendants of a given ancestor. |
|
Selects all elements that are direct children of a specified parent element. |
|
Selects all elements that are the immediately following sibling of a specified element. |
|
Selects all sibling elements that follow after the “prev” element. |
DOM Manipulation
Adding Content
|
Appends content to the end of each element in the set of matched elements. |
|
Inserts content to the beginning of each element in the set of matched elements. |
|
Inserts content after each element in the set of matched elements. |
|
Inserts content before each element in the set of matched elements. |
Removing Content
|
Removes all child nodes from the set of matched elements. |
|
Removes the set of matched elements from the DOM. |
Replacing Content
|
Replaces each element in the set of matched elements with the provided new content. |
Attributes
|
Get the value of an attribute for the first element in the set of matched elements. |
|
Set one or more attributes for the set of matched elements. |
|
Remove an attribute from each element in the set of matched elements. |
CSS
|
Get the value of a computed style property for the first element in the set of matched elements. |
|
Set one or more CSS properties for the set of matched elements. |
Events
Basic Events
|
Binds an event handler to the “click” JavaScript event. |
|
Binds an event handler to the “dblclick” JavaScript event. |
|
Binds an event handler to the “mouseenter” JavaScript event. |
|
Binds an event handler to the “mouseleave” JavaScript event. |
|
A shorthand method for |
|
Binds an event handler to the “mousedown” JavaScript event. |
|
Binds an event handler to the “mouseup” JavaScript event. |
|
Binds an event handler to the “keydown” JavaScript event. |
|
Binds an event handler to the “keyup” JavaScript event. |
Event Handling
|
Attaches an event handler function for one or more events to the selected elements. |
|
Remove an event handler. |
|
Execute all handlers and behaviors attached to the matched elements for the given event type. |
Effects
Basic Effects
|
Displays the matched elements. |
|
Hides the matched elements. |
|
Displays or hides the matched elements. |
Fading
|
Fades in the matched elements. |
|
Fades out the matched elements. |
|
Adjusts the opacity of the matched elements. |
|
Fades in or out the matched elements. |
Sliding
|
Slides down the matched elements. |
|
Slides up the matched elements. |
|
Slides up or down the matched elements. |
Animation
|
Performs a custom animation of a set of CSS properties. |
|
Stop the currently-running animation on the matched elements. |