Difference between revisions of "Small jQuery Cheat Sheet"
Line 5: | Line 5: | ||
Most of the stuff here is just DOM and events related. AJAX etc. is best described in [http://api.jquery.com/ jQuery docs]. | Most of the stuff here is just DOM and events related. AJAX etc. is best described in [http://api.jquery.com/ jQuery docs]. | ||
− | + | === .add() === | |
Add elements to the set of matched elements. | Add elements to the set of matched elements. | ||
.add( selector ) | .add( selector ) | ||
Line 19: | Line 19: | ||
* '''context''' The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method. | * '''context''' The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method. | ||
− | + | === .addClass() === | |
Adds the specified class(es) to each of the set of matched elements. | Adds the specified class(es) to each of the set of matched elements. | ||
.addClass( className ) | .addClass( className ) | ||
Line 26: | Line 26: | ||
* '''function(index, currentClass)''' A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, ''this'' refers to the current element in the set. | * '''function(index, currentClass)''' A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, ''this'' refers to the current element in the set. | ||
− | + | === .after() and .before() === | |
− | Insert content, specified by the parameter, after each element in the set of matched elements. | + | Insert content, specified by the parameter, after/before each element in the set of matched elements. |
.after( content [, content] ) | .after( content [, content] ) | ||
− | * '''content''' HTML string, DOM element, or jQuery object to insert after each element in the set of matched elements. | + | .before( content [, content] ) |
− | * '''content''' One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. | + | * '''content''' HTML string, DOM element, or jQuery object to insert after/before each element in the set of matched elements. |
+ | * '''content''' One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after/before each element in the set of matched elements. | ||
.after( function(index) ) | .after( function(index) ) | ||
− | * '''function(index)''' A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, ''this'' refers to the current element in the set. | + | .before( function ) |
+ | * '''function(index)''' A function that returns an HTML string, DOM element(s), or jQuery object to insert after/before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, ''this'' refers to the current element in the set. | ||
− | + | === .animate() === | |
Perform a custom animation of a set of CSS properties. | Perform a custom animation of a set of CSS properties. | ||
.animate( properties [, duration] [, easing] [, complete] ) | .animate( properties [, duration] [, easing] [, complete] ) | ||
Line 51: | Line 53: | ||
** specialEasing: A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions (added 1.4). | ** specialEasing: A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions (added 1.4). | ||
− | + | === .append() === | |
Insert content, specified by the parameter, to the end of each element in the set of matched elements. | Insert content, specified by the parameter, to the end of each element in the set of matched elements. | ||
.append( content [, content] ) | .append( content [, content] ) | ||
Line 59: | Line 61: | ||
* '''function(index, html)''' A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, ''this'' refers to the current element in the set. | * '''function(index, html)''' A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, ''this'' refers to the current element in the set. | ||
− | + | === .attr() === | |
Get the value of an attribute for the first element in the set of matched elements. | Get the value of an attribute for the first element in the set of matched elements. | ||
.attr( attributeName ) | .attr( attributeName ) | ||
Line 72: | Line 74: | ||
* '''function(index, attr)''' A function returning the value to set. ''this'' is the current element. Receives the index position of the element in the set and the old attribute value as arguments. | * '''function(index, attr)''' A function returning the value to set. ''this'' is the current element. Receives the index position of the element in the set and the old attribute value as arguments. | ||
− | + | === .children() === | |
− | + | ||
− | + | ||
− | + | ||
Get the children of each element in the set of matched elements, optionally filtered by a selector. | Get the children of each element in the set of matched elements, optionally filtered by a selector. | ||
+ | .children( [selector] ) | ||
+ | * '''selector''' A string containing a selector expression to match elements against. | ||
− | + | === .clearQueue() === | |
Remove from the queue all items that have not yet been run. | Remove from the queue all items that have not yet been run. | ||
+ | .clearQueue( [queueName] ) | ||
+ | * '''queueName''' A string containing the name of the queue. Defaults to ''fx'', the standard effects queue. | ||
− | + | === .click() === | |
Bind an event handler to the "click" JavaScript event, or trigger that event on an element. | Bind an event handler to the "click" JavaScript event, or trigger that event on an element. | ||
− | + | .click( handler(eventObject) ) | |
+ | * '''handler(eventObject)''' A function to execute each time the event is triggered. | ||
+ | .click( [eventData], handler(eventObject) ) | ||
+ | * '''eventData''' A map of data that will be passed to the event handler. | ||
+ | * '''handler(eventObject)''' A function to execute each time the event is triggered. | ||
+ | .click() | ||
+ | Trigger the "click" event. | ||
+ | |||
+ | === .css() === | ||
Get the value of a style property for the first element in the set of matched elements. | Get the value of a style property for the first element in the set of matched elements. | ||
− | ==== . | + | .css( propertyName ) |
+ | * '''propertyName''' A CSS property. | ||
+ | .css( propertyName, value ) | ||
+ | * '''propertyName''' A CSS property name. | ||
+ | * '''value''' A value to set for the property. | ||
+ | .css( propertyName, function(index, value) ) | ||
+ | * '''propertyName''' A CSS property name. | ||
+ | * '''function(index, value)''' A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. | ||
+ | .css( map ) | ||
+ | * '''map''' A map of property-value pairs to set. | ||
+ | |||
+ | === .dblclick() === | ||
+ | Bind an event handler to the "dblclick" JavaScript event, or trigger that event on an element. | ||
+ | .dblclick( handler(eventObject) ) | ||
+ | * '''handler(eventObject)''' A function to execute each time the event is triggered. | ||
+ | .dblclick( [eventData], handler(eventObject) ) | ||
+ | * '''eventData''' A map of data that will be passed to the event handler. | ||
+ | * '''handler(eventObject)''' A function to execute each time the event is triggered. | ||
+ | .dblclick() | ||
+ | Trigger the "dblclick" event. | ||
+ | |||
+ | === .delay() === | ||
Set a timer to delay execution of subsequent items in the queue. | Set a timer to delay execution of subsequent items in the queue. | ||
− | + | .delay( duration [, queueName] ) | |
+ | * '''duration''' An integer indicating the number of milliseconds to delay execution of the next item in the queue. | ||
+ | * '''queueName''' A string containing the name of the queue. Defaults to fx, the standard effects queue. | ||
+ | |||
+ | === .each() === | ||
Iterate over a jQuery object, executing a function for each matched element. | Iterate over a jQuery object, executing a function for each matched element. | ||
− | + | .each( function(index, Element) ) | |
− | Display the matched elements by fading them to opaque. | + | * '''function(index, Element)''' A function to execute for each matched element. |
− | + | ||
− | + | === .fadeIn() and .fadeOut() === | |
− | + | Display/Hide the matched elements by fading them to opaque/transparent. | |
+ | .fadeIn( [duration] [, callback] ) | ||
+ | .fadeOut( [duration] [, callback] ) | ||
+ | * '''duration''' A string or number determining how long the animation will run. | ||
+ | * '''callback''' A function to call once the animation is complete. | ||
+ | .fadeIn( [duration] [, easing] [, callback] ) | ||
+ | .fadeOut( [duration] [, easing] [, callback] ) | ||
+ | * '''duration''' A string or number determining how long the animation will run. | ||
+ | * '''easing''' A string indicating which easing function to use for the transition. | ||
+ | * '''callback''' A function to call once the animation is complete. | ||
+ | |||
+ | === .fadeTo() === | ||
Adjust the opacity of the matched elements. | Adjust the opacity of the matched elements. | ||
− | + | .fadeTo( duration, opacity [, callback] ) | |
+ | * '''duration''' A string or number determining how long the animation will run. | ||
+ | * '''opacity''' A number between 0 and 1 denoting the target opacity. | ||
+ | * '''callback''' A function to call once the animation is complete. | ||
+ | .fadeTo( duration, opacity [, easing] [, callback] ) | ||
+ | * '''duration''' A string or number determining how long the animation will run. | ||
+ | * '''opacity''' A number between 0 and 1 denoting the target opacity. | ||
+ | * '''easing''' A string indicating which easing function to use for the transition. | ||
+ | * '''callback''' A function to call once the animation is complete. | ||
+ | |||
+ | === .fadeToggle() === | ||
Display or hide the matched elements by animating their opacity. | Display or hide the matched elements by animating their opacity. | ||
− | + | .fadeToggle( [duration] [, easing] [, callback] ) | |
+ | * '''duration''' A string or number determining how long the animation will run. | ||
+ | * '''easing''' A string indicating which easing function to use for the transition. | ||
+ | * '''callback''' A function to call once the animation is complete. | ||
+ | |||
+ | === .filter() === | ||
Reduce the set of matched elements to those that match the selector or pass the function's test. | Reduce the set of matched elements to those that match the selector or pass the function's test. | ||
− | + | .filter( selector ) | |
+ | * '''selector''' A string containing a selector expression to match the current set of elements against. | ||
+ | .filter( function(index) ) | ||
+ | * '''function(index)''' A function used as a test for each element in the set. this is the current DOM element. | ||
+ | .filter( element ) | ||
+ | * '''element''' An element to match the current set of elements against. | ||
+ | .filter( jQuery object ) | ||
+ | * '''jQuery object''' An existing jQuery object to match the current set of elements against. | ||
+ | |||
+ | === .find() === | ||
Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. | Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. | ||
− | + | .find( selector ) | |
− | Reduce the set of matched elements to the first in the set. | + | * '''selector''' A string containing a selector expression to match elements against. |
− | + | .find( jQuery object ) | |
+ | * '''jQuery object''' A jQuery object to match elements against. | ||
+ | .find( element ) | ||
+ | * '''element''' An element to match elements against. | ||
+ | |||
+ | === .first() and .last() === | ||
+ | Reduce the set of matched elements to the first/last in the set. | ||
+ | |||
+ | === .focus() === | ||
Bind an event handler to the "focus" JavaScript event, or trigger that event on an element. | Bind an event handler to the "focus" JavaScript event, or trigger that event on an element. | ||
− | + | .focus( handler(eventObject) ) | |
− | + | * '''handler(eventObject)''' A function to execute each time the event is triggered. | |
− | + | .focus( [eventData], handler(eventObject) ) | |
− | Bind an event handler to the "focusout" | + | * '''eventData''' A map of data that will be passed to the event handler. |
− | + | * '''handler(eventObject)''' A function to execute each time the event is triggered. | |
+ | .focus() | ||
+ | Trigger the "focus" event. | ||
+ | |||
+ | === .focusin() and .focusout() === | ||
+ | Bind an event handler to the "focusin"/"focusout" event. | ||
+ | .focusin( handler(eventObject) ) | ||
+ | .focusout( handler(eventObject) ) | ||
+ | * '''handler(eventObject)''' A function to execute each time the event is triggered. | ||
+ | .focusin( [eventData], handler(eventObject) ) | ||
+ | .focusout( [eventData], handler(eventObject) ) | ||
+ | * '''eventData''' A map of data that will be passed to the event handler. | ||
+ | * '''handler(eventObject)''' A function to execute each time the event is triggered. | ||
+ | |||
+ | === .height() === | ||
Get the current computed height for the first element in the set of matched elements. | Get the current computed height for the first element in the set of matched elements. | ||
− | + | ||
+ | === .hide() === | ||
Hide the matched elements. | Hide the matched elements. | ||
− | + | ||
+ | === .hover() === | ||
Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements. | Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements. | ||
− | + | ||
+ | === .html() === | ||
Get the HTML contents of the first element in the set of matched elements. | Get the HTML contents of the first element in the set of matched elements. | ||
− | + | ||
− | + | === .innerHeight() and .innerWidth() === | |
− | + | Get the current computed height/width for the first element in the set of matched elements, including padding but not border. | |
− | Get the current computed width for the first element in the set of matched elements, including padding but not border. | + | |
− | + | === .insertAfter() and .insertBefore() === | |
− | + | Insert every element in the set of matched elements after/before the target. | |
− | + | ||
− | Insert every element in the set of matched elements before the target. | + | === .keydown() and .keyup() === |
− | + | Bind an event handler to the "keydown"/"keyup" JavaScript event, or trigger that event on an element. | |
− | Bind an event handler to the "keydown" JavaScript event, or trigger that event on an element. | + | |
− | + | === .keypress() === | |
Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element. | Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element. | ||
− | + | ||
− | + | === .map() === | |
− | + | ||
− | + | ||
− | + | ||
Pass each element in the current matched set through a function, producing a new jQuery object containing the return values. | Pass each element in the current matched set through a function, producing a new jQuery object containing the return values. | ||
− | + | === .mousedown() === | |
Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element. | Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element. | ||
− | + | === .mouseenter() === | |
Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element. | Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element. | ||
− | + | === .mouseleave() === | |
Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element. | Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element. | ||
− | + | === .mousemove() === | |
Bind an event handler to the "mousemove" JavaScript event, or trigger that event on an element. | Bind an event handler to the "mousemove" JavaScript event, or trigger that event on an element. | ||
− | + | === .mouseout() === | |
Bind an event handler to the "mouseout" JavaScript event, or trigger that event on an element. | Bind an event handler to the "mouseout" JavaScript event, or trigger that event on an element. | ||
− | + | === .mouseover() === | |
Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element. | Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element. | ||
− | + | === .mouseup() === | |
Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element. | Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element. | ||
− | + | === .next() === | |
Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. | Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. | ||
− | + | === .nextAll() === | |
Get all following siblings of each element in the set of matched elements, optionally filtered by a selector. | Get all following siblings of each element in the set of matched elements, optionally filtered by a selector. | ||
− | + | === .nextUntil() === | |
Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. | Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. | ||
− | + | === .outerHeight() === | |
Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements. | Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements. | ||
− | + | === .outerWidth() === | |
Get the current computed width for the first element in the set of matched elements, including padding and border. | Get the current computed width for the first element in the set of matched elements, including padding and border. | ||
− | + | === .parent() === | |
Get the parent of each element in the current set of matched elements, optionally filtered by a selector. | Get the parent of each element in the current set of matched elements, optionally filtered by a selector. | ||
− | + | === .parents() === | |
Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector. | Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector. | ||
− | + | === .position() === | |
Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. | Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. | ||
− | + | === .prepend() === | |
Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. | Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. | ||
− | + | === .prependTo() === | |
Insert every element in the set of matched elements to the beginning of the target. | Insert every element in the set of matched elements to the beginning of the target. | ||
− | + | === .prev() === | |
Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector. | Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector. | ||
− | + | === .remove() === | |
Remove the set of matched elements from the DOM. | Remove the set of matched elements from the DOM. | ||
− | + | === .removeAttr() === | |
Remove an attribute from each element in the set of matched elements. | Remove an attribute from each element in the set of matched elements. | ||
− | + | === .removeClass() === | |
Remove a single class, multiple classes, or all classes from each element in the set of matched elements. | Remove a single class, multiple classes, or all classes from each element in the set of matched elements. | ||
− | + | === .resize() === | |
Bind an event handler to the "resize" JavaScript event, or trigger that event on an element. | Bind an event handler to the "resize" JavaScript event, or trigger that event on an element. | ||
− | + | === .scroll() === | |
Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element. | Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element. | ||
− | + | === .scrollLeft() === | |
Get the current horizontal position of the scroll bar for the first element in the set of matched elements. | Get the current horizontal position of the scroll bar for the first element in the set of matched elements. | ||
− | + | === .scrollTop() === | |
Get the current vertical position of the scroll bar for the first element in the set of matched elements. | Get the current vertical position of the scroll bar for the first element in the set of matched elements. | ||
− | + | === .select() === | |
Bind an event handler to the "select" JavaScript event, or trigger that event on an element. | Bind an event handler to the "select" JavaScript event, or trigger that event on an element. | ||
− | + | === .show() === | |
Display the matched elements. | Display the matched elements. | ||
− | + | === .siblings() === | |
Get the siblings of each element in the set of matched elements, optionally filtered by a selector. | Get the siblings of each element in the set of matched elements, optionally filtered by a selector. | ||
− | + | === .slideDown() === | |
Display the matched elements with a sliding motion. | Display the matched elements with a sliding motion. | ||
− | + | === .slideToggle() === | |
Display or hide the matched elements with a sliding motion. | Display or hide the matched elements with a sliding motion. | ||
− | + | === .slideUp() === | |
Hide the matched elements with a sliding motion. | Hide the matched elements with a sliding motion. | ||
− | + | === .stop() === | |
Stop the currently-running animation on the matched elements. | Stop the currently-running animation on the matched elements. | ||
− | + | === .submit() === | |
Bind an event handler to the "submit" JavaScript event, or trigger that event on an element. | Bind an event handler to the "submit" JavaScript event, or trigger that event on an element. | ||
− | + | === .text() === | |
Get the combined text contents of each element in the set of matched elements, including their descendants. | Get the combined text contents of each element in the set of matched elements, including their descendants. | ||
− | + | === .toggle() === | |
Display or hide the matched elements. | Display or hide the matched elements. | ||
− | + | === .toggle() === | |
Bind two or more handlers to the matched elements, to be executed on alternate clicks. | Bind two or more handlers to the matched elements, to be executed on alternate clicks. | ||
− | + | === .toggleClass() === | |
Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. | Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. | ||
− | + | === .val() === | |
Get the current value of the first element in the set of matched elements. | Get the current value of the first element in the set of matched elements. | ||
− | + | === .width() === | |
Get the current computed width for the first element in the set of matched elements. | Get the current computed width for the first element in the set of matched elements. | ||
− | + | === .wrap() === | |
Wrap an HTML structure around each element in the set of matched elements. | Wrap an HTML structure around each element in the set of matched elements. | ||
− | + | === .wrapAll() === | |
Wrap an HTML structure around all elements in the set of matched elements. | Wrap an HTML structure around all elements in the set of matched elements. | ||
− | + | === .wrapInner() === | |
Wrap an HTML structure around the content of each element in the set of matched elements. | Wrap an HTML structure around the content of each element in the set of matched elements. |
Revision as of 22:39, 8 April 2012
I always forget this stuff... is it click() or onclick()? Hope this will be helpful to others too.
This is by no means definite or complete guide... well, it's a cheat sheet. Most of the stuff here is just DOM and events related. AJAX etc. is best described in jQuery docs.
Contents
- 1 .add()
- 2 .addClass()
- 3 .after() and .before()
- 4 .animate()
- 5 .append()
- 6 .attr()
- 7 .children()
- 8 .clearQueue()
- 9 .click()
- 10 .css()
- 11 .dblclick()
- 12 .delay()
- 13 .each()
- 14 .fadeIn() and .fadeOut()
- 15 .fadeTo()
- 16 .fadeToggle()
- 17 .filter()
- 18 .find()
- 19 .first() and .last()
- 20 .focus()
- 21 .focusin() and .focusout()
- 22 .height()
- 23 .hide()
- 24 .hover()
- 25 .html()
- 26 .innerHeight() and .innerWidth()
- 27 .insertAfter() and .insertBefore()
- 28 .keydown() and .keyup()
- 29 .keypress()
- 30 .map()
- 31 .mousedown()
- 32 .mouseenter()
- 33 .mouseleave()
- 34 .mousemove()
- 35 .mouseout()
- 36 .mouseover()
- 37 .mouseup()
- 38 .next()
- 39 .nextAll()
- 40 .nextUntil()
- 41 .outerHeight()
- 42 .outerWidth()
- 43 .parent()
- 44 .parents()
- 45 .position()
- 46 .prepend()
- 47 .prependTo()
- 48 .prev()
- 49 .remove()
- 50 .removeAttr()
- 51 .removeClass()
- 52 .resize()
- 53 .scroll()
- 54 .scrollLeft()
- 55 .scrollTop()
- 56 .select()
- 57 .show()
- 58 .siblings()
- 59 .slideDown()
- 60 .slideToggle()
- 61 .slideUp()
- 62 .stop()
- 63 .submit()
- 64 .text()
- 65 .toggle()
- 66 .toggle()
- 67 .toggleClass()
- 68 .val()
- 69 .width()
- 70 .wrap()
- 71 .wrapAll()
- 72 .wrapInner()
.add()
Add elements to the set of matched elements.
.add( selector )
- selector A string representing a selector expression to find additional elements to add to the set of matched elements.
.add( elements )
- elements One or more elements to add to the set of matched elements.
.add( html )
- html An HTML fragment to add to the set of matched elements.
.add( jQuery object )
- jQuery object An existing jQuery object to add to the set of matched elements.
.add( selector, context )
- selector A string representing a selector expression to find additional elements to add to the set of matched elements.
- context The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method.
.addClass()
Adds the specified class(es) to each of the set of matched elements.
.addClass( className )
- className One or more class names to be added to the class attribute of each matched element.
.addClass( function(index, currentClass) )
- function(index, currentClass) A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set.
.after() and .before()
Insert content, specified by the parameter, after/before each element in the set of matched elements.
.after( content [, content] ) .before( content [, content] )
- content HTML string, DOM element, or jQuery object to insert after/before each element in the set of matched elements.
- content One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after/before each element in the set of matched elements.
.after( function(index) ) .before( function )
- function(index) A function that returns an HTML string, DOM element(s), or jQuery object to insert after/before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set.
.animate()
Perform a custom animation of a set of CSS properties.
.animate( properties [, duration] [, easing] [, complete] )
- properties A map of CSS properties that the animation will move toward.
- duration A string or number determining how long the animation will run.
- easing A string indicating which easing function to use for the transition.
- complete A function to call once the animation is complete.
.animate( properties, options )
- properties A map of CSS properties that the animation will move toward.
- options A map of additional options to pass to the method. Supported keys:
- duration: A string or number determining how long the animation will run.
- easing: A string indicating which easing function to use for the transition.
- complete: A function to call once the animation is complete.
- step: A function to be called after each step of the animation.
- queue: A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string.
- specialEasing: A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions (added 1.4).
.append()
Insert content, specified by the parameter, to the end of each element in the set of matched elements.
.append( content [, content] )
- content DOM element, HTML string, or jQuery object to insert at the end of each element in the set of matched elements.
- content One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements.
.append( function(index, html) )
- function(index, html) A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set.
.attr()
Get the value of an attribute for the first element in the set of matched elements.
.attr( attributeName )
- attributeName The name of the attribute to get.
.attr( attributeName, value )
- attributeName The name of the attribute to set.
- value A value to set for the attribute.
.attr( map )
- map A map of attribute-value pairs to set.
.attr( attributeName, function(index, attr) )
- attributeName The name of the attribute to set.
- function(index, attr) A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments.
.children()
Get the children of each element in the set of matched elements, optionally filtered by a selector.
.children( [selector] )
- selector A string containing a selector expression to match elements against.
.clearQueue()
Remove from the queue all items that have not yet been run.
.clearQueue( [queueName] )
- queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
.click()
Bind an event handler to the "click" JavaScript event, or trigger that event on an element.
.click( handler(eventObject) )
- handler(eventObject) A function to execute each time the event is triggered.
.click( [eventData], handler(eventObject) )
- eventData A map of data that will be passed to the event handler.
- handler(eventObject) A function to execute each time the event is triggered.
.click()
Trigger the "click" event.
.css()
Get the value of a style property for the first element in the set of matched elements.
.css( propertyName )
- propertyName A CSS property.
.css( propertyName, value )
- propertyName A CSS property name.
- value A value to set for the property.
.css( propertyName, function(index, value) )
- propertyName A CSS property name.
- function(index, value) A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
.css( map )
- map A map of property-value pairs to set.
.dblclick()
Bind an event handler to the "dblclick" JavaScript event, or trigger that event on an element.
.dblclick( handler(eventObject) )
- handler(eventObject) A function to execute each time the event is triggered.
.dblclick( [eventData], handler(eventObject) )
- eventData A map of data that will be passed to the event handler.
- handler(eventObject) A function to execute each time the event is triggered.
.dblclick()
Trigger the "dblclick" event.
.delay()
Set a timer to delay execution of subsequent items in the queue.
.delay( duration [, queueName] )
- duration An integer indicating the number of milliseconds to delay execution of the next item in the queue.
- queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
.each()
Iterate over a jQuery object, executing a function for each matched element.
.each( function(index, Element) )
- function(index, Element) A function to execute for each matched element.
.fadeIn() and .fadeOut()
Display/Hide the matched elements by fading them to opaque/transparent.
.fadeIn( [duration] [, callback] ) .fadeOut( [duration] [, callback] )
- duration A string or number determining how long the animation will run.
- callback A function to call once the animation is complete.
.fadeIn( [duration] [, easing] [, callback] ) .fadeOut( [duration] [, easing] [, callback] )
- duration A string or number determining how long the animation will run.
- easing A string indicating which easing function to use for the transition.
- callback A function to call once the animation is complete.
.fadeTo()
Adjust the opacity of the matched elements.
.fadeTo( duration, opacity [, callback] )
- duration A string or number determining how long the animation will run.
- opacity A number between 0 and 1 denoting the target opacity.
- callback A function to call once the animation is complete.
.fadeTo( duration, opacity [, easing] [, callback] )
- duration A string or number determining how long the animation will run.
- opacity A number between 0 and 1 denoting the target opacity.
- easing A string indicating which easing function to use for the transition.
- callback A function to call once the animation is complete.
.fadeToggle()
Display or hide the matched elements by animating their opacity.
.fadeToggle( [duration] [, easing] [, callback] )
- duration A string or number determining how long the animation will run.
- easing A string indicating which easing function to use for the transition.
- callback A function to call once the animation is complete.
.filter()
Reduce the set of matched elements to those that match the selector or pass the function's test.
.filter( selector )
- selector A string containing a selector expression to match the current set of elements against.
.filter( function(index) )
- function(index) A function used as a test for each element in the set. this is the current DOM element.
.filter( element )
- element An element to match the current set of elements against.
.filter( jQuery object )
- jQuery object An existing jQuery object to match the current set of elements against.
.find()
Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
.find( selector )
- selector A string containing a selector expression to match elements against.
.find( jQuery object )
- jQuery object A jQuery object to match elements against.
.find( element )
- element An element to match elements against.
.first() and .last()
Reduce the set of matched elements to the first/last in the set.
.focus()
Bind an event handler to the "focus" JavaScript event, or trigger that event on an element.
.focus( handler(eventObject) )
- handler(eventObject) A function to execute each time the event is triggered.
.focus( [eventData], handler(eventObject) )
- eventData A map of data that will be passed to the event handler.
- handler(eventObject) A function to execute each time the event is triggered.
.focus()
Trigger the "focus" event.
.focusin() and .focusout()
Bind an event handler to the "focusin"/"focusout" event.
.focusin( handler(eventObject) ) .focusout( handler(eventObject) )
- handler(eventObject) A function to execute each time the event is triggered.
.focusin( [eventData], handler(eventObject) ) .focusout( [eventData], handler(eventObject) )
- eventData A map of data that will be passed to the event handler.
- handler(eventObject) A function to execute each time the event is triggered.
.height()
Get the current computed height for the first element in the set of matched elements.
.hide()
Hide the matched elements.
.hover()
Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.
.html()
Get the HTML contents of the first element in the set of matched elements.
.innerHeight() and .innerWidth()
Get the current computed height/width for the first element in the set of matched elements, including padding but not border.
.insertAfter() and .insertBefore()
Insert every element in the set of matched elements after/before the target.
.keydown() and .keyup()
Bind an event handler to the "keydown"/"keyup" JavaScript event, or trigger that event on an element.
.keypress()
Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element.
.map()
Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
.mousedown()
Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element.
.mouseenter()
Bind an event handler to be fired when the mouse enters an element, or trigger that handler on an element.
.mouseleave()
Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element.
.mousemove()
Bind an event handler to the "mousemove" JavaScript event, or trigger that event on an element.
.mouseout()
Bind an event handler to the "mouseout" JavaScript event, or trigger that event on an element.
.mouseover()
Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element.
.mouseup()
Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element.
.next()
Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
.nextAll()
Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.
.nextUntil()
Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed.
.outerHeight()
Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements.
.outerWidth()
Get the current computed width for the first element in the set of matched elements, including padding and border.
.parent()
Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
.parents()
Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
.position()
Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
.prepend()
Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
.prependTo()
Insert every element in the set of matched elements to the beginning of the target.
.prev()
Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.
.remove()
Remove the set of matched elements from the DOM.
.removeAttr()
Remove an attribute from each element in the set of matched elements.
.removeClass()
Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
.resize()
Bind an event handler to the "resize" JavaScript event, or trigger that event on an element.
.scroll()
Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element.
.scrollLeft()
Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
.scrollTop()
Get the current vertical position of the scroll bar for the first element in the set of matched elements.
.select()
Bind an event handler to the "select" JavaScript event, or trigger that event on an element.
.show()
Display the matched elements.
.siblings()
Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
.slideDown()
Display the matched elements with a sliding motion.
.slideToggle()
Display or hide the matched elements with a sliding motion.
.slideUp()
Hide the matched elements with a sliding motion.
.stop()
Stop the currently-running animation on the matched elements.
.submit()
Bind an event handler to the "submit" JavaScript event, or trigger that event on an element.
.text()
Get the combined text contents of each element in the set of matched elements, including their descendants.
.toggle()
Display or hide the matched elements.
.toggle()
Bind two or more handlers to the matched elements, to be executed on alternate clicks.
.toggleClass()
Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
.val()
Get the current value of the first element in the set of matched elements.
.width()
Get the current computed width for the first element in the set of matched elements.
.wrap()
Wrap an HTML structure around each element in the set of matched elements.
.wrapAll()
Wrap an HTML structure around all elements in the set of matched elements.
.wrapInner()
Wrap an HTML structure around the content of each element in the set of matched elements.