Accepts a string containing a CSS selector which is then used to match a set of elements.
A string containing a selector expression
Find all div elements
$("div", xml.responseXML);
Accepts a string containing a CSS selector which is then used to match a set of elements.
A string containing a selector expression
A DOM Element, Document, or jQuery to use as context
Find all div elements within an XML document from an Ajax reponse.
$("div", xml.responseXML);
At present, the only operations supported on plain JavaScript objects wrapped in jQuery are:
.data(), .prop(), .bind(), .unbind(), .trigger() and .triggerHandler().
A plain object to wrap in a jQuery object.
Define a plain object, wrap it with jQuery, and test accesing property values.
var foo = {foo:'bar', hello:'world'};
var $foo = $(foo);
var test1 = $foo.prop('foo');
Accepts an array containing a set of DOM elements to wrap in a jQuery object.
An array containing a set of DOM elements to wrap in a jQuery object.
Calling the jQuery() method with no arguments returns an empty jQuery set (with a .length property of 0).
Creates DOM elements on the fly from the provided string of raw HTML.
A string of HTML to create on the fly. Note that this parse HTML, not XML.
A document in which the new elements will be created
Create a div element (and all of its contents) dynamically and append it to the body element.
$("<div><p>Hello</p></div>").appendTo("body");
Creates DOM elements on the fly from the provided string of raw HTML.
A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).
An map of attributes, events, and methods to call on the newly-created element.
Create some DOM elements.
$("<div/>", {
"class": "test",
text: "Click me!",
click: function() {
$(this).toggleClass("test");
}
}).appendTo("body");
The DOM node context originally passed to jQuery().
Determine the exact context used.
$("ul").append("<li>" + $("ul").context + "</li>")
.append("<li>" + $("ul", document.body).context.nodeName + "</li>");
Hook directly into jQuery to override how particular CSS properties are retrieved or set.
(function($) {
// first, check to see if cssHooks are supported
if (!$.cssHooks) {
throw("jQUery 1.4.3 or above is required");
return;
}
$.cssHooks["someCSSProp"] = {
get: function(elem, computed, extra) {
// handle getting the CSS propety
},
set: function(elem, value) {
// handle setting the CSS value
}
};
})(jQuery);
fx is a global jQuery object.
A string containing the jQuery version number.
The number of elements in the jQuery object.
A collection of properties that represent the presence of different browser features or bugs.
Primarily intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally
to improve page startup performance.
Add elements to the set of matched elements.
A string representing a selector expression to find additional elements or HTML fragment to add to the set of matched elements.
Add <div> into <p> and save it to a variable:
var pdiv = $("p").add("div");
Add elements to the set of matched elements.
One or more elements to add to the set of matched elements.
Add elements to the set of matched elements.
An existing jQuery object to add to the set of matched elements.
Add elements to the set of matched elements.
A string representing a selector expression to find additional elements to add to the set of matched elements.
The point in the document at which the selector should begin matching; similiar to the context argument of the $(selector, context) method.
Adds the specified class(es) to each of the set of matched elements.
One or more class names to be added to the class attribute of each matched element.
More than one class may be added at a time, separated by a space, to the set of matched elements, like so:
$("p").addClass("myClass yourClass");
Adds the specified class(es) to each of the set of matched elements based on a function return value.
The function 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) is a function returning one or more space-separated class names<br>
to be added to the existing class name(s). Receives the index position of the element <br>
in the set and the existing class name(s) as arguments. Within the function, <br>
this refers to the current element in the set.
Given an unorderer list with five <li> elements, this example add the class "item-4" to the last <li>:
$("ul li:last").addClass(function(index) {
return "item-" + index;
});
Insert content, specified by the parameter, after each element in the set of matched elements.
HTML string, DOM element, or jQuery object to insert after each element in the set of matched elements.
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.
Insert some HTML after all paragraphs.
$("p").after("<b>Hello</b>");
Insert content, specified by a function, after each element in the set of matched elements. The parameter function
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.
function(index) is a function that returns an HTML string, DOM element(s), or jQuery object <br>
to insert after each matched element. Receives the index position of the element in the set as an argument.<br>
Within the function, this refers to the current element in the set.
Given an unorderer list with five <li> elements, this example add the class "item-4" to the last <li>:
$("ul li:last").addClass(function(index) {
return "item-" + index;
});
Perform an asynchronous HTTP (Ajax) request.
A string containing the URL to which the request is sent.
A set of key/value pairs that configure the Ajax request.
Save some data to the server and notify the user once it's complete.
$.ajax({
type: "POST",
url: "some.php",
data: {name: "John", location: "Boston"}
}).done(function(msg) {
alert("Data Saved: " + msg);
});
Perform an asynchronous HTTP (Ajax) request.
A set of key/value pairs that configure the Ajax request. All settings are optional.
Specifying a DOM element as the context will make that the context for the complete callback of a request, like so:
$.ajax({
url: "test.html",
context: document.body
}).done(function(){
$(this).addClass("done");
});
Register a handler to be called when Ajax requests complete. This is an Ajax Event.
handler(event, XMLHttpRequest, ajaxOptions) is the function to be invoked.
Show a message when an Ajax request completes.
$("#msg").ajaxComplete(function(event, request, settings) {
$(this).append("<li>Request Complete.</li>");
});
Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event.
handler(event, jqXHR, ajaxSettings, thrownError) The function to be invoked.
Show a message when an Ajax request fails.
$("#msg").ajaxError(function(event, request, settings) {
$(this).append("<li>Error requesting page " + settings.url + "</li>");
});
Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
An optional String containing one or more space-separated dataTypes.
handler(options, originalOptions, jqXHR) A handler to set default values for future Ajax requests.
Proxies cross-domain request through http://mydomain.net/proxy/:
$.ajaxPrefilter(function(options) {
if (options.crossDomain) {
options.url = "http://mydomain.net/proxy/" + encodeURIComponent(options.url);
options.crossDomain = false;
}
});
Attach a function to be executed before an Ajax request is sent. This is an Ajax Event.
handler(event, jqXHR, ajaxOptions) The function to be invoked.
Show a message before an Ajax request is sent.
$("#msg").ajaxSend(function(evt, request, settings) {
$(this).append("<li>Starting request at " + settings.url + "</li>");
});
Set default values for future Ajax requests.
A set of key/value pairs that configure the default Ajax request. All options are optional.
Set the defaults for Ajax requests to the url "/xmlhttp/",
disables global handlers and uses POST instead of GET.
The following Ajax requests then sends some data without having to set anything else.
$.ajaxSetup({
url: "/xmlhttp",
global: false,
type: "POST"
});
$.ajax({data: myData});
Register a handler to be called when the first Ajax request begins. This is an Ajax event.
handler() is the function to be invoked.
Show a loading message whenever an Ajax request starts (and none is already active).
$("#loading").ajaxStart(function() {
$(this).show();
});
Register a handler to be called when all Ajax requests have completed. This is an Ajax event.
handler() is the function to be invoked.
Hide a loading message after all the Ajax requests have stopped.
$("#loading").ajaxStop(function() {
$(this).hide();
});
Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event.
handler(event, XMLHttpRequest, ajaxOptions) The function to be invoked.
Show a message when an Ajax request completes successfully.
$("#msg").ajaxSuccess(function(evt, request, settings) {
$(this).append("<li>Successful Request!</li>");
});
Add the previous set of elements on the stack to the current set.
Find all divs, and all the paragraphs inside of them, and give them bot class names.
$("div").find("p").andSelf().addClass("border");
Notice the div doesn't have the yellow backgroud color since it didn't use .andSelf():
$("div").find("p").addClass("background");
Perform a custom animation of a set of CSS properties
A map of CSS properties that the animation will move toward.
A string or number determininmg how long the animation will run.
A string indicating which easing function to use for the transition.
A function to call once the animation is complete. The callback is not sent any <br>
arguments, but this is set to the DOM element being animated.
$("#go").click(function() {
$("#block").animate({
width: "70%",
marginLeft: "0.6in",
}, 1500);
});
$("#right").click(function() {
$(".block").animate({"left": "+=50px"}, "slow");
});
Perform a custom animation of a set of CSS properties.
A map of CSS properties that the animation will move toward.
A map of additional options to pass to the method.
$("#clickme").click(function() {
$("#book").animate({
width: 'toggle',
height: 'toggle'
}, {
duration: 6000,
specialEasing: {
width: 'linear',
height: 'easeOutBounce'
},
complete: function() {
$(this).after('<div>Animation complete.</div>');
}
});
});
Insert content, specified by the parameter, to the end of each element in the set of matched elements.
DOM element, HTML string, or jQuery object to insert at the end of matched elements.
One or more additional DOM element, array of elements, HTML strings, or jQuery objects to insert at the end of matched elements.
Appends some HTML to all paragraphs.
$("p").append("<strong>Hello</strong>");
Insert content, specified by the parameter, to the end of each element in the set of matched elements.
function(index, html) is a function that returns an HTML string, DOM element(s), or jQuery object<br>
to insert at the end of each matched elements.
Insert every element in the set of matched elements to the end of the target.
A selector, element, HTML string, or jQuery object; matched set of elements will be inserted at the end of this parameter.
Appends all spans to the element with the ID "foo"
$("span").appendTo("#foo");
Get the value of an attribute for the first element in the set of matched elements.
The name of the attribute to get.
Find the title attribute of the first <em> in the page.
var title = $("em").attr("title");
Set one or more attributes for the set of matched elements.
The name of the attribute to set.
A value to set for the attribute.
To change the alt attribute.
$('#greatphoto').attr('alt', 'Beijing Brush Seller');
Set one or more attributes for the set of matched elements.
A map of attribute-value pairs to set.
$('#greatphoto').attr({
alt: 'Beijing Brush Seller',
title: 'photo by Kelly Clark'
});
Set one or more attributes for the set of matched elements.
The name of the attribute to set.
function(index, attr) is a function returning the value to set.<br>
this is the current element. Receives the index position of the element<br>
in the set and the old attribute value as arguments.
$('#greatphoto').attr('title', function(i, val) {
return val + ' - photo by Kelly Clark'
});
Insert content, specified by the parameter, before each element in the set of matched elements.
HTML string, DOM element, or jQuery object to insert before each matched elements.
One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each matched elements.
Insert some HTML before all paragraphs.
$("p").before("<b>Hello</b>");
Insert content, specified by the parameter, before each element in the set of matched elements.
A function that returns an HTML string, DOM element(s), or jQuery object to insert before <br>
each matched elements. Receives the index position of the element in the set as an argument.<br>
Within the function, this refers to the current element in the set.
Attach a handler to an event for the elements.
A string containing one or more DOM event types, such as "click" or "submit".
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered. Within the handler,<br>
this refers to the DOM element to which the handler is bound.
Handle click and double-click for the paragraph.
$("p").bind("click", function(event) {
var str = "(" + event.pageX + ", " + event.pageY + " )";
$("span").text("Click happened! " + str);
});
$("p").bind("dblclick", function() {
$("span").text("Double-click happened in " + this.nodeName);
});
Attach a handler to an event for the elements.
A string containing one or more DOM event types, such as "click" or "submit".
A map of data that will be passed to the event handler.
Setting the third arguments to false will attach a function that prevents the default action from occuring and stops the event from bubbling.
Attach a handler to an event for the elements.
A map of one or more DOM event types and functions to execute for them.
Bind multipe event handlers simultaneously.
$('#foo').bind({
click: function() { // do something on click },
mouseenter: function() { // do something on mouseenter }
});
Bind an event handler to the "blur" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
$('#target').blur(function() {
alert('Handler for .blur() called.');
});
Bind an event handler to the "blur" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "blur" JavaScript event on an element.
To trigger the blur event on all paragraphs.
$("p").blur();
A multi-purpose callback list object that provides a powerful way to manage callback lists.
An optional list of space-separated flags that change how the callback list behaves.
function fn1(value) {
console.log(value);
return false;
}
function fn2(value) {
console.log(value);
return false;
}
var callbacks = $.Callbacks("stopOnFalse");
callbacks.add(fn1);
callbacks.fire("foo"); // output: foo
callbacks.add(fn2);
callbacks.fire("bar"); // output: bar (fn1 will not fired again)
Bind an event handler to the "change" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Attaches a change event to the select that gets the text for each
selected option and writes them in the div.
$("select").change(function() {
var str = "";
$("select option:selected").each(function() {
str += $(this).text() + " ";
});
$("div").text(str);
});
Bind an event handler to the "change" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "change" JavaScript event on an element.
Get the children of each element in the set of matched elements.
A string containing a selector expression to match elements against.
Find all children of the clicked element.
$("#container").click(function(e) {
var $kids = $(e.target).children();
});
Remove from the queue all items that have not yet been run.
A string containing the name of the queue. Defaults to fx.
Empty the queue.
var myDiv = $("div");
myDiv.clearQueue();
myDiv.stop();
Bind an event handler to the "click" JavaScript event.
A function to execute each time the event is triggered.
Hide paragraphs on a page when they are clicked.
$("p").click(function() {
$(this).slideUp();
});
Bind an event handler to the "click" JavaScript event.
A map of data that will be passed to the event handler.
A function to execute each time the event is triggered.
Trigger "click" JavaScript event on an element.
Create a deep copy of the set of matched elements.
A Boolean indicating whether event handlers should be copied along with the elements.
$("b").clone().prependTo("p");
Create a deep copy of the set of matched elements.
A Boolean indicating whether event handlers should be copied along with the elements.
A Boolean indicating whether event handlers and data for all children of the cloned element should be copied.
$("b").clone().prependTo("p");
For each element in the set, get the first element that matches the selector.
A string containing a selector expression to match elements against.
The closest list element toggles a yellow background
when it or its descendent is clicked.
$(document).bind("click", function(e) {
$(e.target).closest("li").toggleClass("hilight");
});
For each element in the set, get the first element that matches the selector.
A string containing a selector expression to match elements against.
A DOM element within which a matching element may be found.
For each element in the set, get the first element that matches the selector.
A jQuery object to match elements agains.
For each element in the set, get the first element that matches the selector.
An element to match elements against.
Check to see if a DOM element is within another DOM element.
The DOM element that may contains the other element.
The DOM element that may be contained by the other element.
Check if an element is inside another.
jQuery.contains(document.documentElement, document.body); // true
jQUery.contains(document.body, document.documentElement); //false
Get the children of each element in the set of matched elements.
Find all the text nodes inside a paragraph
and wrap them with a bold tag.
$("p").contents().filter(function() {
return this.nodeType!=1;
}).wrap("<b/>");
Get the value of a style property for the first element in matched elements.
A CSS property.
Access the background color of a clicked div.
var color = $(this).css("background-color");
Set one or more CSS properties for the set of matched elements.
A CSS property name.
A value to set for the property.
To change the color of any paragraph to red on mouseover event.
$("p").mouseover(function() {
$(this).css("color", "red");
});
Set one or more CSS properties for the set of matched elements.
A CSS property name.
function(index, value) is a function returning the value to set. this is the current element.<br>
Receives the index position of the element in the set and the old value as arguments.
$('div.example').css('width', function(index) {
return index * 50;
});
Set one or more CSS properties for the set of matched elements.
A map of property-value pairs to set.
To set the color of all paragraphs to red and background to blue:
var cssObj = {
'background-color': '#ddd',
'font-weight': '',
'color': 'rgb(0,40,244)'
};
$(this).css(cssObj);
Store arbitrary data associated with the matched elements.
A string naming the piece of data to set.
The new data value; it can be any Javascript type including Array or Object.
$("div").data("test", {first: 16, last: "pizza!"});
Store arbitrary data associated with the matched elements.
An object of key-value pairs of data to update.
Returns value at named data store for the first element in the jQuery collection, as set by data(name,value).
Name of the data stored.
alert($('body').data('foo'));
Returns value at named data store for the first element in the jQuery collection, as set by data(name,value).
alert($('body').data());
Store arbitrary data associated with the specified element.
The DOM element to associate with the data.
A string naming the piece of data to set.
The new data value.
Store then retrieve a value from the div element.
jQuery.data(div, "test", {first:16, last:"pizza!"});
$("span:first").text(jQuery.data(div, "test").first);
Returns value at named data store for the element.
The DOM element to query for the data.
Name of the data stored.
alert(jQuery.data(document.body, 'foo'));
Returns value at named data store for the element.
The DOM element to query for the data.
alert(jQuery.data(document.body));
Bind an event handler to the "dblclick" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
$("p").dblclick(function(){ alert("Hello World!");});
Bind an event handler to the "dblclick" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "dblclick" JavaScript event on an element.
Create Deferred object.
Set a timer to delay execution of subsequent items in the queue.
An integer indicating the number of milliseconds to delay execution of the next item in the queue.
A string containing the name of the queue.
Animate the hiding and showing of two divs, delaying the first before showing it.
$("button").click(function() {
$("div.first").slideUp(300).delay(800).fadeIn(400);
$("div.second").slideUp(300).fadeIn(400);
});
Attach a handler to one or more events for all elements that match the selector, now or in the future.
A selector to filter the elements that trigger the event.
A string containing one or more space-separated JvaScript event types, such as "click" or "keydown".
hanlder(eventObject) is a function to execute at the time the event is triggered.
.delegate(0 attaches a click event handler to all paragraphs - even new ones.
$("body").delegate("p", "click", function() {
$(this).after("<p>Another paragraph!</p>");
});
Attach a handler to one or more events for all elements that match the selector, now or in the future.
A selector to filter the elements that trigger the event.
A string containing one or more space-separated JvaScript event types, such as "click" or "keydown".
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute at the time the event is triggered.
Attach a handler to one or more events for all elements that match the selector, now or in the future.
A selector to filter the elements that trigger the event.
A map of one or more event types and functions to execute for them.
Execute the next function on the queue for the matched elements.
A string containing the name of the queue.
Use dequeue to end a custome queue function.
$("div").queue(function() {
$(this).toggleClass("red");
$(this).dequeue();
});
Execute the next function on the queue for the matched element.
A DOM element from which to remove and execute a queued function.
A string containing the name of the queue.
Use jQuery.dequeue() to end a custom queue function
which allows the queue to keep going.
$("div").queue(function() {
$(this).toggleClass("red");
$.dequeue(this);
});
Remove the set of matched elements from the DOM.
A selector expression that filters matched elements to be removed.
Detach all paragraphs from the DOM.
var p = $("p").detach();
A generic interator function, which can be used to seamlessly iterate over both objects and arrays.
Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index,
from 0 to length-1. Other object are iterated via their named properties.
The object or array to iterate over.
callback(indexInArray, valueOfElement) is the function that will be executed on every object.
Iterates through the array displaying each number as both a word and numeral.
var arr = ["one", "two", "three", "four", "five" ];
var obj = {one:1, two:2, three:3, four:4, five:5 };
jQuery.each(arr, function() {
$("#" + this).text("Mine is " + this + ".");
return (this!="three"); //will stop running after "Three"
});
jQuery.each(obj, function(i, val) {
$("#" + i).append(document.createTextNode(" - " + val));
});
Iterate over a jQuery object, executing a function for each matched element.
function(index, element) is a function to execute for each matched element.
Iterates over three divs and sets their color property.
$("div").each(function(i) {
if (this.style.color!="blue") {
this.style.color="blue";
} else {
this.style.color="";
}
});
Remove all the child nodes of the set of matched elements from the DOM.
Remove all child nodes (including text nodes) from all paragraphs.
$("p").empty();
End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.
Select all paragraphs, find span elements inside these, and reverts the selection back to the paragraph.
$("p").showTags(0).find("span").showTags(1).css("background", "yellow")
.end().showTags(2).css("font-style", "italic");
Reduce the set of matched elements to the one at the specified index.
An integer indicating 0-based position of the element. If integer is minus, <br>
indicating the position of element, counting backwards from the last element in the set.
Turn the div with index 2 blue by adding an appropriate class.
$("body").find("div").eq(2).addClass("blue");
Bind an event handler to the "error" JavaScript event.
handler(eventObject) is a function to execute when the event is triggered.
To hide the "broken image" icons for IE users.
$("img").error(function() {
$(this).hide();
}).attr("src", "missing.png");
Bind an event handler to the "error" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute when the event is triggered.
Takes a string and throws an exception containing it.
The message to send out.
Override jQuery.error for display in Firebug.
jQuery.error = console.error;
Create a new jQuery.Event object.
A string represents event name.
Object that specifies event properties.
Create a new jQuery.Event object with specified event properties.
var e = jQuery.Event("keydown", {keyCode:64});
Merge the contents of two or more objects together into the first object.
An object that will receive the new properties if additional objects are passed in <br>
or that will extends the jQuery namespace if it is the sole argument.
An object containing additional properties to merge in.
Additional objects containing properties to merge in.
Merge two objects, modifying the first.
var object1 = { apple: 0, banana: {weight: 52, price: 100}, cherry: 97 },
var object2 = { banana: {price: 200}, durian: 100};
$.extend(object1, object2);
// result object1={"apple":0, "banana":{"price":200}, "cherry":97, "durian":100}
Merge the contents of two or more objects together into the first object.
If true, the merge becomes recursive (aka. deep copy).
An object that will receive the new properties if additional objects are passed in <br>
or that will extends the jQuery namespace if it is the sole argument.
An object containing additional properties to merge in.
Additional objects containing properties to merge in.
Merge two objects recursively, modifying the first.
var object1 = { apple: 0, banana: {weight: 52, price: 100}, cherry: 97 },
var object2 = { banana: {price: 200}, durian: 100};
$.extend(true, object1, object2);
// result object1={"apple":0, "banana":{"weight":52,"price":200},"cherry":97,"durian":100}
Display the matched elements by fading them to opaque.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A function to call once the animation is complete.
Animates hidden divs to fade in one by one, completing each animation withing 600 ms.
$(document.body).click(function() {
$("div:hidden:first").fadeIn("slow");
});
Display the matched elements by fading them to opaque.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Hide the matched elements by fading them to transparent.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A function to call once the animation is complete.
Animates all paragraphs by fade out, comleting the animation within 600 ms.
$("p").fadeOut("slow");
Hide the matched elements by fading them to transparent.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Adjust the opacity of the matched elements.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A number between 0 and 1 denoting the target opacity.
A function to call once the animation is complete.
Animates first paragraph to fade to an opacity 0.33 (33%, about
one third visible), completing the animation within 600 milliseconds.
$("p:first").click(function() {
$(this).fadeTo("slow", 0.33);
});
Adjust the opacity of the matched elements.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A number between 0 and 1 denoting the target opacity.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Animates first paragraph to fade to an opacity 0.33 (33%, about
one third visible), completing the animation within 600 milliseconds.
$("p:first").click(function() {
$(this).fadeTo("slow", 0.33);
});
Display or hide the matched elements by animating their opacity.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Fades first paragraph in or out, completing their animation within 600 ms and using
a linear easing. Fades last paragraph in or out for 200 ms, inserting a "finished" message upon completion.
$("p:first").fadeToggle("slow", "linear");
$("p:last").fadeToggle("fast", function() {
$("#log").append("<div>finished</div>");
});
Reduce the set of matched elements to those that match the selector or pass the function's test.
A string containing a selector expression to match the current set of elements against.
$('li').filter(':even').css('background-color', 'red');
Reduce the set of matched elements to those that match the selector or pass the function's test.
function(index) is a function used as a test for each element in the set. <br>
this is the current DOM element.
$('li').filter(function(index) {
return $('strong', this).length==1;
}).css('background-color', 'red');
Reduce the set of matched elements to those that match the selector or pass the function's test.
An element to match the current set of elements against.
Select all divs and filter the selection with a DOM element, keeping only
the one with an id of "unique".
$("div").filter(document.getElementById("unique"));
Reduce the set of matched elements to those that match the selector or pass the function's test.
An existing jQuery object to match the current set of elements against.
Get the descendants of each element in the curernt set of matched elements, filtered by a selector, jQuery object, or element.
A string containing a selector expression to match elements against.
Start with all paragraphs and searches for descendant span elements,
same as $("p span").
$("p").find("span").css("color", "red");
Get the descendants of each element in the curernt set of matched elements, filtered by a selector, jQuery object, or element.
A jQuery object to match elements against.
A selection using a jQuery collection of all span tags. Only span within p tags
are changed to red while others are left blue.
var $spans = $('span');
$("p").find($spans).css('color', 'red');
Get the descendants of each element in the curernt set of matched elements, filtered by a selector, jQuery object, or element.
An element to match elements against.
Reduce the set of matched elements to the first in the set.
Highlight the first span in the paragraph.
$("p span").first().addClass('highlight');
Bind an event handler to the "focus" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
$("input").focus(function() {
$(this).next("span").css('display', 'inline').fadeOut(1000);
});
Bind an event handler to the "focus" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "focus" JavaScript event on an element.
Bind an event handler to the "focusin" event.
handler(eventObject) is a function to execute each time the event is triggered.
$("p").focusin(function() {
$(this).find("span").css('display', 'inline').fadeOut(1000);
});
Bind an event handler to the "focusin" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "focusout" event.
handler(eventObject) is a function to execute each time the event is triggered.
Watch for a loss of focus to occur inside paragraphs and note the difference
between the focusout count and the blur count.
$("p").focusout(function() {
foo++; $("#fo").text("focusout fired: " + fo + "x");
}).blur(function() {
b++; $("#b").text("blur fired: " + b + "x");
});
Bind an event handler to the "focusout" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Load data from the server using a HTTP GET request.
A string containing the URL to which the request is sent.
A map or string that is sent to the server with the request.
success(data, textStatus, jqXHR) is a callback function that is executed if the request succeeds.
The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
Alert out the result from requesting test.cgi with an additional payload of data
(HTML or XML, depending on what was returned).
$.get("test.cgi", {name: "John", time: "2pm"},
function(data) {
alert("Data Loaded: " + data);
});
Retrieve the DOM elements matched by the jQuery object.
A zero-based integer indicating which element to retrieve.
Select all divs in the document and returns the DOM Elements as an Array, then
uses the build-in reverse-method to reverse that array.
display($("div").get().reverse());
Load JSON-encoded data from the server using a GET HTTP request.
A string containing the URL to which the request is sent.
A map or string that is sent to the server with the request.
success(data, textStatus, jqXHR) is a callback function that is executed if the request succeeds.
Loads the four most recent cat picture from the Flickr JSON API.
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
{ tags: "mount rainier", tagmode: "any", format: "json"},
function(data) {
... // called if succeed
}
});
Load a JavaScript file from the server using a GET HTTP request, then execute it.
A string containing the URL to which the request is sent.
success(script, textstatus, jqXHR) is a callback function that is executed if the request succeeds.
$.getScript("/scripts/jquery.color.js", function() {
$("#go").click(function() {
...
}
});
Execute some JavaScript code globally.
The JavaScript code to execute.
Execute a script in the global context.
function test() {
jQuery.globalEval("var newVar = true;");
}
test(); // newVar === true
Finds the elements of an array which satisfy a filter function. The original array is not affected.
The array to search through.
function(elementOfArray, indexInArray) is a function to process each item against.<br>
The first argument to the function is the item, and the second argument is the index.<br>
The function should return a Boolean value. this will be the global window object.
If "invert" is false, or not provided, then the function returns an array consisting <br>
of all elements for which "callback" returns true. If "invert" is true, then the function <br>
returns an array consisting of all elements for which "callback" return false.
Filters the original array of numbers leaving that are not 5 and having an index greater than 4.
var arr = [1,9,3,8,6,1,5,9,4,7,3,8,6,9,1];
$("div").text(arr.join(", "));
arr = jQuery.grep(arr, function(n, i) {
return (n!=5 && i>4);
});
Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
A string containing a selector expression to match elements against.
$("ul").has("li").addClass("full");
Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
A DOM element to match elements against.
Determine whether any of the matched elements are assigned the given class.
The class name to search for.
Looks for the paragraph that contains 'selected' as a class.
$("div#result1").append($("p:first").hasClass("selected").toString());
Determine whether an element has any jQuery data associated with it.
A DOM element to be checked for data.
Set data on an element and see the results of hasData.
$.data(p, "testing", 123);
$p.append(jQuery.hasData(p)+" "); /* true */
Get the current computed height for the first element in the set of matched elements.
$("p").height();
Set the CSS height of every matched element.
An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a String).
To set the height of each div to 30px plus a color change.
$("div").height(30).css({cursor:"auto", backgroundColor:"green"});
Set the CSS height of every matched element.
function(index, height) is a function returning the height to set. Receives the index <br>
position of the element in the set and the old height as arguments. Within the function, <br>
this refers to the current element in the set.
Hide the matched elements.
Hide the matched elements.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A function to call once the animation is complete.
Hide the matched elements.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Holds or release the execution of jQuery's ready event.
Indicates whether the ready hold is being requested or released.
Delay the ready event until a custom plugin has loaded.
$.holdReady(true);
$.getScript("myplugin.js", function() {
$.holdReady(false);
});
Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.
handlerIn(eventObject) is a function to execute when the mouse pointer enters the element.
handlerOut(eventObject) is a function to execute when the mouse pointer leaves the element.
To add a special style to list items that are being hovered over.
$("li.fade").hover(function() {
$(this).fadeOut(100); $(this).fadeIn(500);
});
Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements.
handlerInOut(eventObject) is a function to execute when the mouse pointer enters or leaves the element.
Slide the next sibling LI up or down on hover, and toggle a class.
$("li").filter(":odd").hide().end()
.filter(":even").hover(function() {
$(this).toggleClass("active").next().stop(true,true).slideToggle();
});
Get the HTML contents of the first element in the set of matched elements.
var htmlStr = $(this).html();
Set the HTML contents of each element in the set of matched elements.
A string of HTML to set as the content of each matched element.
Add some html to each div.
$("div").html("<span class='red'>Hello <b>Again</b></span>");
Set the HTML contents of each element in the set of matched elements.
function(index,oldhtml) is a function returning the HTML content to set. Receives the index position <br>
of the element in the set nad the old HTML value as arguments. jQuery empties the element before calling <br>
the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the <br>
current element in the set.
Add some html to each div.
$("div").html("<span class='red'>Hello <b>Again</b></span>");
Seach for a specified value within an array and return its index (or -1 if not found).
The value to search for.
An array through which to search.
The index of the array at which to begin the search. Default is 0.
Report the index of some elements in the array.
$spans.eq(0).text(jQuery.inArray("John", arr));
Search for a given element from among the matched elements. The return value is an integer indication
the position of the first element within the jQuery object relative to its sibling elements.
var index = $("div").index(this);
Search for a given element from among the matched elements.
A selector representing a jQuery collection in which to look for an element.
Search for a given element from among the matched elements.
The DOM element or first element within the jQuery object to look for.
Get the current computed height for the first element in the set of matched elements, including padding but not border.
$("p:last").text("innerHeight:" + p.innerHeight());
Get the current computed width for the first element in the set of matched elements, including padding but not border.
$("p:last").text("innerWidth:" + p.innerWidth());
Insert every element in the set of matched elements after the target.
A selector, element, HTML string, or jQuery object; the matched set of elements<br>
will be inserted after the element(s) specified by this parameter.
Inserts all paragraphs after an element with id of "foo".
$("p").insertAfter("#foo");
Insert every element in the set of matched elements before the target.
A selector, element, HTML string, or jQuery object; the matched set of elements<br>
will be inserted after the element(s) specified by this parameter.
Inserts all paragraphs before an element with id of "foo".
$("p").insertBefore("#foo");
Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
A string containing a selector expression to match elements against.
Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
function(index) is a function used as a test for the set of elements. It accepts one argument, <br>
index, which is the element's index in the jQuery collection. Within the function, this refers to the current DOM element.
Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
An existing jQuery object to match the current set of elements against.
Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
An element to match the current set of elements against.
Determine whether the argument is an array.
Object to test whether or not it is an array.
Check to see if an object is empty (contains no properties).
Object that will be checked to see if it's empty.
Determine if the argument passed is a Javascript function object.
Object to test whether or not it is a function.
Determine whether its argument is a number.
The value to be tested.
Check to see if an object is a plain object (created using "{}" or "new Object").
Object that will be checked to see if it's a plain object.
Determine whether the argument is a window.
Object to test whether or not it is a window.
Check to see if a DOM node is within an XML document (or is an XML document).
The DOM node that will be checked to see if it's in an XML document.
Bind an event handler to the "keydown" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "keydown" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "keydown" Javascript event on an element.
Bind an event handler to the "keypress" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "keypress" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "keypress" Javascript event on an element.
Bind an event handler to the "keyup" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "keyup" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "keyup" Javascript event on an element.
Reduce the set of matched elements to the final one in the set.
Highlight the last span in a paragraph.
$("p span").last().addClass('highlight');
Load data from the server and place the returned HTML into matched element.
A string containing the URL to which the request is sent.
A map or string that is sent to the server with the request.
complete(responseText, textStatus, XMLHttpRequest) is a callback function that is <br>
executed when the request completes.
Load the main page's footer navigation into an orderer list.
$("#new-nav").load("/ #jq-footerNavigation li");
Convert an array-like object into a true JavaScript array.
Any object to turn into a native Array.
Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
callback(index, domElement) is a function object that will be invoked for each element in the current set.
Build a list of all the values within a form.
$("p").append($("input").map(function() {
return $(this).val();
}).get().join(", "));
Translate all items in an array or objct to new array or items.
The array to translate.
callback(elementOfArray, indexInArray) is the function to process each item against.<br>
The first argument is the array item, the second argument is the index in array.<br>
The function can return any value. Within the function, this refers to global (window) object.
arr = jQuery.map(arr, function(n,i) {
return (n.toUpperCase()+i);
});
Translate all items in an array or objct to new array or items.
The array or object to translate.
callback(value, indexOrKey) is the function to process each item against.<br>
The first argument is the value; the second argument is the index or key of the array or object property.<br>
The function can return any value. A returned array will be flattened into the resulting array.<br>
Within the function, this refers to global (window) object.
Map the original object to a new array and double each value.
var dimensions = { width: 10, height: 15, length: 20};
dimensions = $.map(dimensions, function(value,index) {
return value*2;
});
Merge the contents of two arrays together into the first array.
The first array to merge, the elements of second added.
The second array to merge into the first, unaltered.
Merge two arrays, altering the first argument.
$.merge( [0,1,2], [2,3,4] ); // result: [0,1,2,3,4]
Bind an event handler to the "mousedown" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "mousedown" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "mousedown" JavaScript event on an element.
Bind an event handler to the "mouseenter" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "mouseenter" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "mouseenter" JavaScript event on an element.
Bind an event handler to the "mouseleave" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "mouseleave" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "mouseleave" JavaScript event on an element.
Bind an event handler to the "mousemove" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "mousemove" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "mousemove" JavaScript event on an element.
Bind an event handler to the "mouseout" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "mouseout" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "mouseout" JavaScript event on an element.
Bind an event handler to the "mouseover" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "mouseover" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "mouseover" JavaScript event on an element.
Bind an event handler to the "mouseup" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "mouseup" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "mouseup" JavaScript event on an element.
Get the immediately following sibling of each element in thext set of matched elements.
If a selector is provided, it retrieves the next sibling only if it matches that selector.
A string containing a selector expression to match elements against.
Find the very next sibling of each paragraph. Keep only the ones with a class "selected".
$("p").next(".selected").css("background", "yellow");
Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.
A string containing a selector expression to match elements against.
Locate all the divs after the first and give them a class.
$("div:first").nextAll().addClass("after");
Get all following siblings of each element up to but not including the element matched by
the selector, DOM node, or jQuery object passed.
A string containing a selector expression to indicate where to stop matching following sibling elements.
A string containing a selector expression to match elements against.
Find the siblings that folow <dt id="term-2"> up to the next <dt> and give them a red backgroud color.
$("#term-2").nextUntil("dt").css("background-color", "red");
Relinquish jQuery's control of $ variable.
A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself).
jQuery.noConflict() {function() {
// code using jQuery
});
// other code using $ as an alias to the other library
An empty function
Remove elements from the set of matched elements.
A string containing a selector expresion to match elements against.
Adds a border to divs that are not green or blue.
$("div").not(".green, #blueone").css("border-color", "red");
Remove elements from the set of matched elements.
One or more DOM elements to remove from the matched set.
Remove elements from the set of matched elements.
function(index) is a function used as a test for each element in the set.<br>
this is the current DOM element.
Remove elements from the set of matched elements.
An existing jQuery object to match the current set of elements against.
Return a number representing the current time. This is a shorthand for (new Date()).getTime().
Remove an event handler.
One or more space-separated event types and optional namespaces, or just namespaces, <br>
such as "click", "keydown.myPlugin", or ".myPlugin".
A selector which should match the one originally passed to .on() when attaching event handlers.
A handler function previously attached for the event(s), or false.
Add and remove event handlers on the colored button.
function aClick() { $("div").show().fadeOut("slow"); }
$("body").on("click", "#theone", aClick);
$("body").off("click", "#theone", aClick);
Remove an event handler.
A map where the string keys represent one or more space-separated event types and optional namespace, <br>
and the values represent handler functions previously attached for the event(s).
A selector which should match the one originally passed to .on() when attaching event handlers.
Get the current coordinates of the first element in the set of matched elements, relative to the document.
Access the offset of the second paragraph.
var p = $("p:last");
var offset = p.offset();
Set the current coordinates of every element in the set of matched elements, relative to the document.
An object containing the properties top and left, which are integers indicating <br>
the new top and left coordinates for the elements.
Set the offset of the second paragraph.
$("p:last").offset({top:10, left:30});
Set the current coordinates of every element in the set of matched elements, relative to the document.
function(index, coords) is a function to return the coordinates to set. Receives the index <br>
of the element in the collection as the first argument and the current coordinates as the <br>
second argument. The function should return an object with the new top and left properties.
Get the closest ancestor element that is positioned.
Find the offsetParent of item "A".
$('li.item-a').offsetParent().css('background-color', 'red');
Attach an event handler function for one or more events to the selected elements.
One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
A selector string to filter the descendants of the selected elements that trigger the event. <br>
If the selector is null or omitted, the event is always triggered when it reaches the selected element.
Data to be passed to the handler in event.data when an event is triggered.
handler(eventObject) is a function to execute when event is triggered. <br>
The value false is also allowed as a shorthand for a function that simpy does return false.
Cancel a form submit action and prevent the event from bubbling up.
$("form").on("submit", false);
Attach an event handler function for one or more events to the selected elements.
A map in which the string keys represent one or more space-separated event types and <br>
optional namespaces, and the values represent a handler function to be called for the event(s).
A selector string to filter the descendants of the selected elements that trigger the event. <br>
If the selector is null or omitted, the event is always triggered when it reaches the selected element.
Data to be passed to the handler in event.data when an event is triggered.
$("div.test").on({
click: function() { $(this).toggleClass("active"); },
mouseenter: function() { $(this).toggleClass("inside"); },
mouseleave: function() { $(this).toggleClass("inside"); }
});
Attach a handler to an event for the elements. The handler is executed at most once per element.
A string containing one or more JavaScript event types, such as "click" or "submit", or custom event names.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute at the time the event is triggered.
Attach a handler to an event for the elements. The handler is executed at most once per element.
A string containing one or more JavaScript event types, such as "click" or "submit", or custom event names.
A selector string to filter the descendants of the selected elements that trigger the event. <br>
If the selector is null or omitted, the event is always triggered when it reaches the selected element.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute at the time the event is triggered.
Tie a one-time click to each div.
$("div").one("click", function() {
...
});
Attach a handler to an event for the elements. The handler is executed at most once per element.
A map in which the string keys represent one or more space-separated event types and optional namespaces,<br>
and the values represent a handler function to be called for the event(s).
A selector string to filter the descendants of the selected elements that trigger the event. <br>
If the selector is null or omitted, the event is always triggered when it reaches the selected element.
A map of data that will be passed to the event handler.
Get the current computed height for the first element in the set of matched elements, including
padding, border, and optionally margin. Return an integer (without "px") representation of the value or null if called on an empty set of elements.
A Boolean indicating whether to include the element's margin in the calculation.
Get the outerHeight of a paragraph.
var p = $("p:first");
$("p:last").text("outerHeight:" + p.outerHeight());
Get the current computed width for the first element in the set of matched elements, including
padding, border, and optionally margin. Return an integer (without "px") representation of the value or null if called on an empty set of elements.
A Boolean indicating whether to include the element's margin in the calculation.
Get the outerHeight of a paragraph.
var p = $("p:first");
$("p:last").text("outerHeight:" + p.outerWidth());
Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
An array or object to serialize
Serialize complex object.
$.param({a:{b:1,c:2},d:[3,4,{e:5}]})
// "a[b]=1&a[c]=2&d[]=3&d[]=4&d[2][e]=5"
Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
An array or object to serialize
A Boolean indicating whether to perform a traditional "shallow" serialization.
Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
A string containing a selector expression to match elements against.
var parentTag = $(this).parent().get(0).tagName;
Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
A string containing a selector expression to match elements against.
Find all parent elements of each b.
var parentEls = $("b").parents().map(function() {
return this.tagName;
}).get().join(", ");
Get the ancestors of each element in the current set of matched elements, up to but not including the element
matched by the selector, DOM node, or jQuery object.
A string containing a selector expression to indicate where to stop matching ancestor elements.
A string containing a selector expression to match elements against.
$("li.item-2").parentsUntil(".level-1").css("background-color", "red");
Get the ancestors of each element in the current set of matched elements, up to but not including the element
matched by the selector, DOM node, or jQuery object.
A DOM node or jQuery object indicating where to stop matching ancestor elements.
A string containing a selector expression to match elements against.
$("li.item-2").parentsUntil($("ul.level-1"), ".yes").css("border", "3px solid green");
Takes a well-formed JSON string and returns the resulting JavaScript object.
The JSON string to parse.
Parses a string into an XML document.
A well-formed XML string to be parsed.
Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
Access the position of the second paragraph:
var position = p.position();
Load data from the server using a HTTP POST request.
A string containing the URL to which the request is sent.
A map or string that is sent to the server with the request.
A callback function that is executed if the request succeeds.
The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
Send form data using ajax request.
$.post("test.php", $("#testform").serialize());
Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
DOM element, array of elements, HTML string, or jQuery object to insert at the <br>
beginning of each element in the set of matched elements.
One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects <br>
to insert at the beginning of each element in the set of matched elements.
Prepends some HTML to all paragraphs.
$("p").prepend("<b>Hello</b>");
Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
function(index, html) is a function that returns an HTML string, DOM elements(s) or jQuery object <br>
to insert at the beginning of each element in the set of matched elements. Receives the index position <br>
of the element in the set and the old HTML value of the elements as arguments. Within the function, this refers <br>
to current element in the set.
Insert every element in the set of matched elements to the beginning of the target.
A selector, element, HTML string, or jQuery object; the matched set of elements <br>
will be inserted at the beginning of the element(s) specified by this parameter.
Prepends all spans to the element with the id "foo".
$("span").prependTo("#foo");
Get the immediately preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
A string containing a selector expression to match elements against.
Find very previous sibling of div.
var $curr = $("#start");
$curr = $curr.prev();
Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
A string containing a selector expression to match elements against.
Locate all the divs preceeding the last div and giv them a class.
$("div:last").prevAll().addClass("before");
Get all preceding siblings of each element up to but not including the element matched by selector, DOM node, or jQuery object.
A string containing a selector expression to indicate where to stop matching preceding sibling elements.
A string containing a selector expression to match elements against.
$("#term-3").prevUntil("dt").css("background-color", "red");
Get all preceding siblings of each element up to but not including the element matched by selector, DOM node, or jQuery object.
A string containing a selector expression to indicate where to stop matching preceding sibling elements.
A string containing a selector expression to match element against.
$("#term-3").prevUntil(term1, "dd").css("color", "green");
Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished.
The type of queue that needs to be observed. By default, type is "fx".
Object onto which the promise methods have to be attached.
Resolve the returned Promise when all animations have ended.
$("div").each(function(i) {
$(this).fadeIn().fadeOut(1000*(i+1));
});
$("div").promise().done(function() {
$("p").append(" Finished! ");
});
Get a value of a property for the first element in the set of matched elements.
The name of the propety to get.
$input.attr('checked'); // return 'checked' or ''
$input.prop('checked'); // return true or false
Set one or more properties for the set of matched elements.
The name of the property to set.
A value to set for the property.
Set one or more properties for the set of matched elements.
A map of property-value pairs to set.
Disable all checkboxes on the page.
$("input[type='checkbox']").prop({
disabled: true
});
Set one or more properties for the set of matched elements.
The name of the property to set.
function(index, oldPropertyValue) is a function returning the value to set. Receives the index <br>
position of the element in the set and the old property value as arguments. Within the function, <br>
the keyword this refers to the current element.
Takes a function and returns a new one that will always have a particular context.
The function whose context will be changed.
The object to which the context (this) of the function should be set.
// execute you.test() in the context of the 'you' object
// no matter where it is called
// i.e. the 'this' keyword wil refer to 'you'
var youClick = $.proxy(you.test, you);
Takes a function and returns a new one that will always have a particular context.
The object to which the context (this) of the function should be set.
The name of the function whose context will be changed (should be a property of the context object).
Ensure the context of the function using the "context, function name" signature.
$("#test").click(jQuery.proxy(obj, "test"));
Add a collection of DOM elements onto the jQuery stack.
An array of elements to push onto the stack and make into a new jQuery object.
Add some elements onto the jQuery stack, then pop back off again.
jQuery([]).pushStack(document.getElementsByTagName("div"))
.remove().end();
Add a collection of DOM elements onto the jQuery stack.
An array of elements to push onto the stack and make into a new jQuery object.
The name of a jQuery method that generated the array of elements.
The arguments that were passed in to the jQuery method (for serialization).
Show the queue of functions to be executed on the matched elements.
A string containing the name of the queue. Defaults to fx, the standard effect queue.
Manipulate the queue of functions to be executed on the matched elements.
A string containing the name of the queue. Defaults to fx, the standard effects queue.
An array of functions to replace the current queue contents.
Manipulate the queue of functions to be executed on the matched elements.
A string containing the name of the queue. Defaults to fx, the standard effects queue.
callback(next) is new function to add to the queue, with a function to call that will dequeue the next item.
Queue a custom function.
$("div").queue(function() {
$(this).addClass('newcolor'); $(this).dequeue();
});
Show the queue of functions to be executed on the matched element.
A DOM element to inspect for an attached queue.
A string containing the name of the queue. Defaults to fx, the standard effects queue.
Show the length of the queue.
var n = jQuery.queue($("div")[0], "fx");
$("span").text("Queue length is: " + n.length);
Manipulate the queue of functions to be executed on the matched element.
A DOM element where the array of queued functions is attached.
A string containing the name of the queue. Defaults to fx, the standard effects queue.
An array of function to replace the current queue contents.
Set a queue array to delete the queue.
jQuery.queue($("div")[0], "fx", []);
Manipulate the queue of functions to be executed on the matched element.
A DOM element where the array of queued functions is attached.
A string containing the name of the queue. Defaults to fx, the standard effects queue.
The new function to add to the queue.
Queue a custom function.
jQuery.queue($("div")[0], "fx", function() {
$(this).addClass("newcolor");
jQuery.dequeue(this);
});
Specify a function to execute when the DOM is fully loaded.
A function to execute after the DOM is ready.
Remove the set of matched elements from the DOM.
A selector expression that filters the set of matched elements to be removed.
Remove all paragraphs from the DOM.
$("p").remove();
Remove an attribute from each element in the set of matched elements.
An attribute to remove; as of version 1.7, it can be a space-separated list of attributes.
var input = $(this).next();
input.removeAttr("title");
Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
One or more space-separated classes to be removed from the class attribute of each matched element.
Remove the class 'blue' from the matched elements.
$("p:even").removeClass("blue");
Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
function(index, class) is a function returning one or more space-separated class names to be removed.<br>
Receives the index position of the element in the set and the old class value as arguments.
Remove a previously-stored piece of data.
A string naming the piece of data to delete.
Set a data store then remove it.
$("div").data("test1", "VALUE-1");
$("div").removeData("test1");
Remove a previously-stored piece of data.
An array or space-separated string naming the pieces of data to delete.
Remove a previously-stored piece of data.
A DOM element from which to remove data.
A string naming the piece of data to remove.
var div = $("div")[0];
jQuery.removeData(div, "test1");
Remove a property for the set of matched elements.
The name of the property to set.
var $para = $("p");
$para.prop("luggageCode", 1234);
$para.removeProp("luggageCode");
Replace each target element with the set of matched elements.
A selector expression indicating which element(s) to replace.
Replace all paragraphs with bold words.
$("<b>paragraph</b>").replaceAll("p");
Replace each element in the set of matched elements with the provided new content.
The content to insert. May be an HTML string, DOM element, or jQuery object.
Replace the button with a div containing the same word.
$("button").replaceWith("<div>" + $("button").text() + "</div>");
Replace each element in the set of matched elements with the provided new content.
function is a function that returns content with which to replace the set of matched elements.
Bind an event handler to the "resize" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "resize" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "resize" JavaScript event on an element.
Bind an event handler to the "scroll" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "scroll" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "scroll" JavaScript event on an element.
Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
Set the current horizontal position of the scroll bar for each of the set of matched elements.
An integer indicating the new position to set the scroll bar to.
Get the current vertical position of the scroll bar for the first element in the set of matched elements.
Set the current vertical position of the scroll bar for each of the set of matched elements.
An integer indicating the new position to set the scroll bar to.
Bind an event handler to the "select" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "select" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "select" JavaScript event on an element.
Encode a set of form elements as a string for submission.
var str = $("form").serialize();
$(#results).text(str);
Encode a set of form elements as an array of names and values.
var fields = $(":input").serializeArray();
$("#results").empty();
jQuery.each(fields, function(i, field) {
$("#results").append(field.value + " ");
});
Display the matched elements.
Display the matched elements.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A function to call once the animation is complete.
Display the matched elements.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
A string containing a selector expression to match elements against.
Find all siblings with a class 'selected' of each div.
$("p").siblings(".selected").css("background", "yellow");
Return the number of elements in the jQuery object.
Reduce the set of matched elements to a subset specified by a range of indices.
An integer indicating the 0-based position at which the elements begin to be selected. <br>
If negative, it indicates an offset from the end of the set.
An integer indicating the 0-based position at which the elements stop being selected. <br>
If negative, it indicates an offset from the end of the set. If omitted, the range continues until the end of the set.
Select all paragraphs, then slices the selection to include only the second element.
$("p").slice(1, 2).wrapInner("<b></b>");
Display the matched elements with a sliding motion.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A function to call once the animation is complete.
Display the matched elements with a sliding motion.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Display or hide the matched elements with a sliding motion.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A function to call once the animation is complete.
Display or hide the matched elements with a sliding motion.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Hide the matched elements with a sliding motion.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A function to call once the animation is complete.
Hide the matched elements with a sliding motion.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Stop the currently-running animation on the matched elements.
A boolean indicating whether to remove queued animation as well. Defaults to false.
A boolean indicating whether to complete the current animation immediately. Defaults to false.
Stop the currently-running animation on the matched elements.
The name of the queue in which to stop animations.
A boolean indicating whether to remove queued animation as well. Defaults to false.
A boolean indicating whether to complete the current animation immediately. Defaults to false.
Bind an event handler to the "submit" JavaScript event.
handler(eventObject) is a function to execute each time the event is triggered.
Bind an event handler to the "submit" JavaScript event.
A map of data that will be passed to the event handler.
handler(eventObject) is a function to execute each time the event is triggered.
Trigger "submit" JavaScript event on an element.
Get the combined text contents of each element in the set of matched elements, including their descendants.
Set the content of each element in the set of matched elements to the specified text.
A string of text to set as content of each matched element.
Set the content of each element in the set of matched elements to the specified text.
function(index,text) is a function returning the text content to set. Receives the index <br>
position of the element in the set and the old text value as arguments.
Retrieve all the DOM elements contained in the jQuery set, as an array.
Display or hide the matched elements.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A function to call once the animation is complete.
Display or hide the matched elements.
A string or number determining how long the animation will run.<br>
The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 ms, respectively.
A string indicating which easing function to use for the transition.<br>
The only easing implementations in the jQuery library are the default, calling 'swing', and one that <br>
progresses at a constant pace, called 'linear'.
A function to call once the animation is complete.
Display or hide the matched elements.
A Boolean indicating whether to show or hide the elements.
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.
One or more class names (separated by spaces) to be toggled for each element in the matched set.
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.
One or more class names (separated by spaces) to be toggled for each element in the matched set.
A Boolean value to determine whether the class should be added or removed.
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.
A Boolean value to determine whether the class should be added or removed.
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.
function(index, class, switch) is a function that returns class names to be toggled in the class attribute <br>
of each element in the matched set. Receives the index position of the element in the set, <br>
the old class value, and the switch as arguments.
A Boolean value to determine whether the class should be added or removed.
Execute all handler and behaviors attached to the matched elements for the given event type.
A string containing a JavaScript event type, such as click or submit.
Additional parameters to pass along to the event handler.
Execute all handler and behaviors attached to the matched elements for the given event type.
A jQuery.Event object.
Execute all handlers attached to an element for an event. This method does not cause the default
behaviour of an event to occur (such as a form submission). This method only affects the first matched element. Event
created with this method do not bubble up the DOM hierarchy.
A string containing JavaScript event type, such as click or submit.
An array of additional parameters to pass along to the event handler.
Remove the whitespace from the beginning and end of a string.
The string to trim.
Determine the internal JavaScript [[Class]] of an object.
Object to get the internal JavaScript [[Class]] of.
Remove a previously-attached event handler from the elements.
A string containing a JavaScript event type, such as click or submit.
handler(eventObject) is the function that is to be no longer executed.
Remove a previously-attached event handler from the elements.
A string containing a JavaScript event type, such as click or submit.
Unbinds the corresponding 'return false' function that was bound using .bind(eventType, false).
Remove a previously-attached event handler from the elements.
A JavaScript event object as passed to an event handler.
Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
A selector which will be used to filter the event results.
A string containing a JavaScript event type, such as "click" or "keydown".
Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
A selector which will be used to filter the event results.
A string containing a JavaScript event type, such as "click" or "keydown".
handler(eventObject) is a function to execute at the time the event is triggered.
Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
A selector which will be used to filter the event results.
A map of one or more event types and previously bound functions to unbind from them.
Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
A String containing a namespace to unbind all events from.
Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of
DOM elements, not strings or numbers.
The array of DOM elements.
Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
Get the current value of the first element in the set of matched elements.
Set the value of each element in the set of matched elements.
A string of text or an array of strings corresponding to the value of each matched element to set as selected/checked.
Set the value of each element in the set of matched elements.
function(index, value) is a function returning the value to set. this is the current element. <br>
Receives the index position of the element in the set and the old value as arguments.
Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
One or more Deferred objects, or plain JavaScript objects.
Executing the function myFunc when both ajax requests are successful,
or myFailure if either one has an error.
$.when($.ajax("/page1.php"), $.ajax("/page2.php")
.then(myFunc, myFailure);
Get the current computed width for the first element in the set of matched elements.
Set the CSS width of each element in the set of matched elements.
An integer representing the number of pixels, or an integer along with an optional unit of measure appended.
Set the CSS width of each element in the set of matched elements.
function(index, width) is a function returning the width to set. Receives the index position of the element <br>
in the set and the old width as arguments. Within the function, this refers to the current element in the set.
Wrap an HTML structure around each element in the set of matched elements.
An HTML snippet, selector expression, jQuery object, or DOM element <br>
specifying the structure to wrap around the matched elements.
Wrap an HTML structure around each element in the set of matched elements.
function(index) is a callback function returning the HTML content or jQuery object to wrap around the matched elements.<br>
Receives the index position of the element in the set as an argument. Within the function,<br>
this refers to the current element in the set.
Wrap an HTML structure around all elements in the set of matched elements.
An HTML snippet, selector expression, jQuery object, or DOM element<br>
specifying the structure to wrap around the matched elements.
Wrap an HTML structure around the content of each element in the set of matched elements.
An HTML snippet, selector expression, jQuery object, or DOM element<br>
specifying the structure to wrap around the matched elements.
Wrap an HTML structure around the content of each element in the set of matched elements.
function(index) is a callback function which generates a structure to wrap around the content of the matched elements.<br>
Receives the index position of the element in the set as an argument.<br>
Within the function, this refers to the current element in the set.
Add a callback or a collection of callbacks to a callback list.
A function, or array of functions, that are to be added to the callback list.
Add new callbacks to a callback list.
var foo = function(value) {
console.log('foo:' + value);
}
var callbacks = $.Callbacks();
callbacks.add(foo);
Disable a callback list from doing anything more.
Disable further calls being made to a callback list.
var callbacks = $.Callbacks();
callbacks.add(foo);
callbacks.fire('foo');
callbacks.disable();
Remove all of the callbacks from a list.
Empty a list of callbacks.
var callbacks = $.Callbacks();
callbacks.add(foo);
callbacks.add(bar);
callbacks.empty();
Call all of the callbacks with the given arguments
The argument or list of arguments to pass back to the callback list.
var callbacks = $.Callbacks();
callbacks.add(foo);
callbacks.fire('hello');
callbacks.fire('world');
Determine if the callbacks have already been called at least once.
var callbacks = $.Callbacks();
callbacks.add(foo);
callbacks.fire('hello');
console.log(callbacks.fired());
Call all callbacks in a list with the given context and arguments.
A reference to the context in which the callbacks in the list should be fired.
An argument, or array of arguments, to pass to the callbacks in the list.
Fire a list of callbacks with a specific context and an array of arguments.
var callbacks = $.Callbacks;
callbacks.add(log);
callbacks.fireWith(window, ['foo', 'bar']);
Determine whether a supplied callback is in a list
The callback to search for.
var callbacks = $.Callbacks();
callbacks.add(foo);
console.log(callbacks.has(foo));
console.log(callbacks.has(bar));
Lock a callback list in its current state.
var callbacks = $.Callbacks();
callbacks.lock();
Determine if the callbacks list has been locked.
var callbacks = $.Callbacks();
callbacks.lock();
console.log(callbacks.locked());
Remove a callback or a collection of callbacks from a callback list.
A function, or array of functions, that are to be removed from the callback list.
var callbacks = $.Callbacks();
callbacks.add(foo);
callbacks.fire('hello');
callbacks.remove(foo);
Add handlers to be called when the Deferred object is either resolved or rejected.
A function, or array of functions, that is called when the Deferred is resolved or rejected.
Optional additional functions, or arrays of functions.
Attach a callback for both success and error.
$.get("test.php").always(function() {
alert("$.get completed with success or error callback arguments");
});
Add handlers to be called when the Deferred object is resolved.
A function, or array of functions, that is called when the Deferred is resolved.
Optional additional functions, or arrays of functions.
Resolve a Deferred object when the user clicks a button,
triggering a number of callback functions:
var dfd = $.Deferred();
dfd.done([fn1, fn2], fn3, [fn2, fn1]);
$("button").bind("click", function() {
dfd.resolve("and");
});
Add handlers to be called when the Deferred object is rejected.
A function, or array of functions, that is called when the Deferred is rejected.
Optional additional functions, or arrays of functions.
$.get("test.php")
.done(function(){alert("$.get succeeded");})
.fail(function(){alert("$.get failed!");});
Call the progressCallbacks on a Deferred object with the given args.
Optional arguments that are passed to the progressCallbacks.
Call the progressCallbacks on a Deferred object with the given context and args.
Context passed to the progressCallbacks as the this object.
Optional arguments that are passed to the progressCallbacks.
Utility method to filter and/or chain Deferreds.
An optional function that is called when the Deferred is resolved.
An optional function that is called when the Deferred is rejected.
Filter resolve value.
var defer = $.Deferred(),
filtered = defer.pipe(function(value) {
return value * 2;
});
Utility method to filter and/or chain Deferreds.
An optional function that is called when the Deferred is resolved.
An optional function that is called when the Deferred is rejected.
An optional function that is called when progress notifications are sent to the Deferred.
Add handlers to be called when the Deferred object generates progress notifications.
A function, or array of functions, that is called when the Deferred generates progress notifications.
Return a Deferred's Promise object.
Object onto which the promise methods have to be attached.
Use the target argument to promote an existing object to a Promise:
defer = $.Deferred();
defer.promise(obj);
defer.resolve("John");
obj.done(function(name) {
obj.hello(name); // will alert "Hello John"
}).hello("Karl"); // will alert "Hello Karl"
Reject a Deferred object and call any failCallbacks with the given args.
Optional arguments that are passed to the failCallbacks.
Reject a Deferred object and call any failCallbacks with the given context and args.
Context passed to the failCallbacks as the this object.
Optional arguments that are passed to the failCallbacks.
Resolve a Deferred object and call any doneCallbacks with the given args.
Optional arguments that are passed to the doneCallbacks.
Resolve a Deferred object and call any doneCallbacks with the given context and args.
Context passed to the doneCallbacks as the this object.
Optional arguments that are passed to the doneCallbacks.
Determine the current state of a Deferred object. Return "pending", "resolved" or "rejected".
Add handlers to be called when the Deferred object is resolved or rejected.
A function, or array of functions, called when the Deferred is resolved.
A function, or array of functions, called when the Deferred is rejected.
$.get("test.php").then(
function() { alert("$.get succeeded"); },
function() { alert("$.get failed!"); }
);
Add handlers to be called when the Deferred object is resolved or rejected.
A function, or array of functions, called when the Deferred is resolved.
A function, or array of functions, called when the Deferred is rejected.
A function, or array of function, called when the Deferred notifies progress.
Utility method to filter and/or chain Deferreds.
An optional function that is called when the Deferred is resolved.
An optional function that is called when the Deferred is rejected.
Filter resolve value.
var defer = $.Deferred(),
filtered = defer.pipe(function(value) {
return value * 2;
});
Utility method to filter and/or chain Deferreds.
An optional function that is called when the Deferred is resolved.
An optional function that is called when the Deferred is rejected.
An optional function that is called when progress notifications are sent to the Deferred.
Add handlers to be called when the Deferred object is resolved or rejected.
A function, or array of functions, called when the Deferred is resolved.
A function, or array of functions, called when the Deferred is rejected.
A function, or array of function, called when the Deferred notifies progress.
Add handlers to be called when the Deferred object is either resolved or rejected.
A function, or array of functions, that is called when the Deferred is resolved or rejected.
Optional additional functions, or arrays of functions.
Attach a callback for both success and error.
$.get("test.php").always(function() {
alert("$.get completed with success or error callback arguments");
});
Add handlers to be called when the Deferred object is resolved.
A function, or array of functions, that is called when the Deferred is resolved.
Optional additional functions, or arrays of functions.
Resolve a Deferred object when the user clicks a button,
triggering a number of callback functions:
var dfd = $.Deferred();
dfd.done([fn1, fn2], fn3, [fn2, fn1]);
$("button").bind("click", function() {
dfd.resolve("and");
});
Add handlers to be called when the Deferred object is rejected.
A function, or array of functions, that is called when the Deferred is rejected.
Optional additional functions, or arrays of functions.
$.get("test.php")
.done(function(){alert("$.get succeeded");})
.fail(function(){alert("$.get failed!");});
Determine the current state of a Deferred object. Return "pending", "resolved" or "rejected".
Return HTTP status code or 0 if error flag is set.
Return HTTP status text or empty string if error flag is set.
Return the text response entity body.
Return the document response entity body.
Returns the current state.
Return the header field value from the response of which the filed name matches header, unless the field name is Set-Cookie or Set-Cookie2.
Matches header filed name with this value.
Return all headers from the response, with the exception of those whose field name is Set-Cookie or Set-Cookie2.
Appends an header tot he list of author request headers, or if header is already in the list of author request headers, combines its value with value.
Header name that will be appended.
Header value that will be appended.
Set the Content-Type header for the response to mime.
The new Content-Type.
Cancels any network activity.
Add handlers to be called when the Deferred object is either resolved or rejected.
A function, or array of functions, that is called when the Deferred is resolved or rejected.
Optional additional functions, or arrays of functions.
Attach a callback for both success and error.
$.get("test.php").always(function() {
alert("$.get completed with success or error callback arguments");
});
Add handlers to be called when the Deferred object is resolved.
A function, or array of functions, that is called when the Deferred is resolved.
Optional additional functions, or arrays of functions.
Resolve a Deferred object when the user clicks a button,
triggering a number of callback functions:
var dfd = $.Deferred();
dfd.done([fn1, fn2], fn3, [fn2, fn1]);
$("button").bind("click", function() {
dfd.resolve("and");
});
Add handlers to be called when the Deferred object is rejected.
A function, or array of functions, that is called when the Deferred is rejected.
Optional additional functions, or arrays of functions.
$.get("test.php")
.done(function(){alert("$.get succeeded");})
.fail(function(){alert("$.get failed!");});
Call the progressCallbacks on a Deferred object with the given args.
Optional arguments that are passed to the progressCallbacks.
Call the progressCallbacks on a Deferred object with the given context and args.
Context passed to the progressCallbacks as the this object.
Optional arguments that are passed to the progressCallbacks.
Add handlers to be called when the Deferred object generates progress notifications.
A function, or array of functions, that is called when the Deferred generates progress notifications.
Return a Deferred's Promise object.
Object onto which the promise methods have to be attached.
Use the target argument to promote an existing object to a Promise:
defer = $.Deferred();
defer.promise(obj);
defer.resolve("John");
obj.done(function(name) {
obj.hello(name); // will alert "Hello John"
}).hello("Karl"); // will alert "Hello Karl"
Reject a Deferred object and call any failCallbacks with the given args.
Optional arguments that are passed to the failCallbacks.
Reject a Deferred object and call any failCallbacks with the given context and args.
Context passed to the failCallbacks as the this object.
Optional arguments that are passed to the failCallbacks.
Resolve a Deferred object and call any doneCallbacks with the given args.
Optional arguments that are passed to the doneCallbacks.
Resolve a Deferred object and call any doneCallbacks with the given context and args.
Context passed to the doneCallbacks as the this object.
Optional arguments that are passed to the doneCallbacks.
Determine the current state of a Deferred object. Return "pending", "resolved" or "rejected".
Add handlers to be called when the Deferred object is resolved or rejected.
A function, or array of functions, called when the Deferred is resolved.
A function, or array of functions, called when the Deferred is rejected.
$.get("test.php").then(
function() { alert("$.get succeeded"); },
function() { alert("$.get failed!"); }
);
Add handlers to be called when the Deferred object is resolved or rejected.
A function, or array of functions, called when the Deferred is resolved.
A function, or array of functions, called when the Deferred is rejected.
A function, or array of function, called when the Deferred notifies progress.
Utility method to filter and/or chain Deferreds.
An optional function that is called when the Deferred is resolved.
An optional function that is called when the Deferred is rejected.
Filter resolve value.
var defer = $.Deferred(),
filtered = defer.pipe(function(value) {
return value * 2;
});
Utility method to filter and/or chain Deferreds.
An optional function that is called when the Deferred is resolved.
An optional function that is called when the Deferred is rejected.
An optional function that is<br>called when progress notifications are sent to the Deferred.
The current DOM element within the event bubbling phase.
An optional data map passed to an event method when the current executing handler is bound.
The element where the currently-called jQuery event handler was attached.
The namespace specified when the event was triggered.
The mouse position relative to the left edge of the document.
The mouse position relative to the top edge of the document.
The other DOM element involved in the event, if any.
The last value returned by an event handler that was triggered by this event, unless the value was undefined.
The DOM element that initiated the event.
The difference in milliseconds between the time the browser created the event and January 1, 1970.
Describes the nature of the event.
For key or mouse events, this property indicates the specific key or button that was pressed.
true if the Alt (or Option, on Mac) key was active when the key event was generated. Read only.
A boolean indicating whether the event bubles up through the DOM or not.
The button number that was pressed when the mouse event was fired: Left button=0,
middle button=1 (if present), right button=2. For mice configured for left handed use in which the button actions are
reversed the values are instead read right from left. Read only.
A boolean indicating whether the event is cancelable.
The character value of the key. Read only.
The X coordinate of the mouse pointer in local (DOM content) coordinates. Read only.
The Y coordinate of the mouse pointer in local (DOM content) coordinates. Read only.
true if the Control key was active when the key event was generated. Read only.
Indicates which phase of the event flow is currently being evaluated. Returns an integer value
represented by 3 constants: Event.CAPTURING_PHASE (1), Event.AT_TARGET (2), or Event.BUBBLING_PHASE (3).
true if the Meta (or Command, on Mac) key was active when the key event was generated. Read only.
The X coordinate of the mouse pointer in global (screen) coordinates. Read only.
The Y coordinate of the mouse pointer in global (screen) coordinates. Read only.
true if the Shift key was active when the key event was generated. Read only.
Return wether event.preventDefault() was ever called on this object.
Return wether event.stopImmediatePropogatin() was ever called on this event object.
Return whether event.stopPropagation() was ever called on this event object.
If this method is called, the default action of the event will not be triggered.
Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree.
Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
The rate (in milliseconds) at which animations fire.
Globally disable all animations.