.

jQuery Deconstructed

Navigate the physical jQuery code to see what, where, and how the magic happens

Home

The Deconstructed series is designed to visually and interactively deconstruct the internal code of JavaScript libraries, including jQuery, Prototype and MooTools.

It breaks the physical JavaScript into visual blocks that you can easiliy navigate. Each block opens to reveal its internal code. Clickable hyperlinks allow you to follow program flow.

Instructions: click element headers to view specific code. Click group headers to preview all nested descriptions. CTRL+click group headers to view all nested code. Click function names to view official API docs.

Key

Section A named set of API methods
Extend Members added via extension
Object Members added directly
Function A function or method
Properties Variables or properties
Code Executing code

Theme

Object : jQuery

/*!
 * jQuery JavaScript Library v1.4.2
 * http://jquery.com/
 *
 * Copyright 2010, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2010, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Sat Feb 13 22:33:48 2010 -0500
 */
(function( window, undefined ) {

Section : jQuery Core

Properties : Framework parameters

Object : jQuery prototype

Function : init (jQuery)

Main jQuery function

Properties : internal

Function : size

Return the number of DOM elements matched by the jQuery object

Function : toArray

Retrieve all the DOM elements contained in the jQuery set, as an array

Function : get

Retrieve the DOM elements matched by the jQuery object

Function : pushStack

Add a collection of DOM elements onto the jQuery stack

Function : each

Iterate over a jQuery object, executing a function for each matched element

Function : ready

Specify a function to execute when the DOM is fully loaded

Function : eq

Reduce the set of matched elements to the one at the specified index

Function : first

Reduce the set of matched elements to the first in the set

Function : last

Reduce the set of matched elements to the final one in the set

Function : slice

Reduce the set of matched elements to a subset specified by a range of indices

Function : map

Pass each element in the current matched set through a function, producing a new jQuery object containing the return values

Function : end

End the most recent filtering operation in the current chain and return the set of matched elements to its previous state

Properties : shortcuts to prototype methods

Code : Give the init function the jQuery prototype for later instantiation

Section : Utilities

Function : extend

Merge the contents of two or more objects together into the first object

Extend : Add utility methods

Function : noConflict

Relinquish jQuery's control of the $ variable

Properties : isReady

Function : ready

Specify a function to execute when the DOM is fully loaded

Function : bindReady

Description

Function : isFunction

Determine if the argument passed is a Javascript function object

Function : isArray

Determine whether the argument is an array

Function : isPlainObject

Check to see if an object is a plain object (created using "{}" or "new Object")

Function : isEmptyObject

Check to see if an object is empty (contains no properties)

Function : error

Takes a string and throws an exception containing it

Function : parseJSON

Takes a well-formed JSON string and returns the resulting JavaScript object

Function : noop

An empty function

Function : globalEval

Execute some JavaScript code globally

Function : nodeName

Returns the uppercase node name

Function : each

Iterate over a jQuery object, executing a function for each matched element

Function : trim

Remove the whitespace from the beginning and end of a string

Function : makeArray

Convert an array-like object into a true JavaScript array

Function : inArray

Search for a specified value within an array and return its index (or -1 if not found)

Function : merge

Merge the contents of two arrays together into the first array

Function : grep

Finds the elements of an array which satisfy a filter function. The original array is not affected

Function : map

Translate all items in an array or array-like object to another array of items

Properties : guid

Function : proxy

Takes a function and returns a new one that will always have a particular context

Function : uaMatch

Properties : browser

Code : Browser / DOM setup code

Function : doScrollCheck

Internal function

Function : evalScript

Internal function

Function : access

Mutifunctional method to get and set values to a collection

Function : now

Internal function

Section : Data

Object : attribute names

Properties : misc variables

Extend : data

Properties : cache & expando

Function : data

Store arbitrary data associated with the matched elements

Function : removeData

Remove a previously-stored piece of data

Extend : data (jQuery.fn)

Function : data

Store arbitrary data associated with the matched elements

Function : removeData

Remove a previously-stored piece of data

Extend : Queing

Function : queue

Show the queue of functions to be executed on the matched elements

Function : dequeue

Execute the next function on the queue for the matched element

Extend : Queing (jQuery.fn)

Function : queue

Show the queue of functions to be executed on the matched elements

Function : dequeue

Execute the next function on the queue for the matched element

Function : delay

Set a timer to delay execution of subsequent items in the queue

Function : clearQueue

Remove from the queue all items that have not yet been run.

Section : Attributes

Properties : Regular expressions

Extend : Attributes and classes

Function : attr

Get the value of an attribute for the first element in the set of matched elements

Function : removeAttr

Remove an attribute from each element in the set of matched elements

Function : addClass

Adds the specified class(es) to each of the set of matched elements

Function : removeClass

Remove a single class, multiple classes, or all classes from each element in the set of matched elements

Function : toggleClass

Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument

Function : hasClass

Determine whether any of the matched elements are assigned the given class

Function : val

Get the current value of the first element in the set of matched elements

Extend : Attribute functions

Object : attributes hash

Function : attr

Get the value of an attribute for the first element in the set of matched elements

Section : Events

Properties : Namespacing

Object : Event

Function : add

Bind an event to an element

Object : Global

Function : remove

Detach an event or set of events from an element

Function : trigger

Execute all handlers and behaviors attached to the matched elements for the given event type

Function : handle

Internal function

Properties : Props

Function : fix

Internal function

Properties : Guid

Properties : Proxy

Object : Special

Function : removeEvent

If this method is called, the default action of the event will not be triggered

Object : Event

Function : returnFalse

Returns a value of false

Function : returnTrue

Returns a value of true

Object : Event

Function : preventDefault

Description

Function : stopPropagation

Description

Function : stopImmediatePropagation

Description

Properties : Event code

Code : mouseenter & mouseleave events

Code : submit event

Code : change event

Code : trigger function

Code : focus and blur events

Code : bind and one events

Extend : Event methods

Function : unbind

Remove a previously-attached event handler from the elements

Function : delegate

Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements

Function : undelegate

Remove a handler from the event for all elements which match the current selector, now or in the future, based upon a specific set of root elements

Function : trigger

Execute all handlers and behaviors attached to the matched elements for the given event type

Function : triggerHandler

Execute all handlers attached to an element for an event

Function : toggle

Bind two or more handlers to the matched elements, to be executed on alternate clicks

Function : hover

Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements

Properties : liveMap

Code : live and die functions

Code : liveHandler

Code : liveConvert

Code : Assign events to jQuery prototype

Code : Prevent memory leaks in IE

Properties : Sizzle variables

Function : Sizzle constructor

Function : Sizzle.uniqueSort

Function : Sizzle.matches

Function : Sizzle.find

Function : Sizzle.filter

Function : Sizzle.error

Object : Sizzle selectors

Code : Sizzle code

Section : Selectors

Properties : for selector methods

Function : Utility function for selector methods

Extend : Selector methods

Function : find

Get the descendants of each element in the current set of matched elements, filtered by a selector

Function : has

Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element

Function : not

Remove elements from the set of matched elements

Function : filter

Reduce the set of matched elements to those that match the selector or pass the function's test

Function : is

Check the current matched set of elements against a selector and return true if at least one of these elements matches the selector

Function : closest

Get the first ancestor element that matches the selector, beginning at the current element and progressing up through the DOM tree

Function : index

Search for a given element from among the matched elements

Function : add

Add elements to the set of matched elements

Function : andSelf

Add the previous set of elements on the stack to the current set


          

Code : Assign selectors

Extend : More selector methods

Function : filter

Reduce the set of matched elements to those that match the selector or pass the function's test

Function : dir

Internal function

Function : nth

Selects all elements that are the nth-child of their parent

Function : sibling

Get the siblings of each element in the set of matched elements, optionally filtered by a selector

Section : Manipulation

Properties : HTML variables


          

Extend : Manipulation methods

Function : text

Get the combined text contents of each element in the set of matched elements, including their descendants

Function : wrapAll

Wrap an HTML structure around all elements in the set of matched elements

Function : wrapInner

Wrap an HTML structure around the content of each element in the set of matched elements

Function : wrap

Wrap an HTML structure around each element in the set of matched elements

Function : unwrap

Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place

Function : append

Insert content, specified by the parameter, to the end of each element in the set of matched elements

Function : prepend

Insert content, specified by the parameter, to the beginning of each element in the set of matched elements

Function : before

Insert content, specified by the parameter, before each element in the set of matched elements

Function : after

Insert content, specified by the parameter, after each element in the set of matched elements

Function : remove

Remove the set of matched elements from the DOM

Function : empty

Remove all child nodes of the set of matched elements from the DOM

Function : clone

Create a copy of the set of matched elements

Function : html

Get the HTML contents of the first element in the set of matched elements

Function : replaceWith

Replace each element in the set of matched elements with the provided new content

Function : detach

Remove the set of matched elements from the DOM

Function : domManip

Description

Function : cloneCopyEvent

Internal function

Function : buildFragment

Internal function

Properties : Fragments cache

Code : Assign manipulation methods

Extend : Cleaning

Function : clean

Internal function

Function : cleanData

Internal function

Section : CSS

Properties : regular expressions etc

Function : css

Get the value of a style property for the first element in the set of matched elements

Extend : CSS

Function : style

Internal function

Function : css

Get the value of a style property for the first element in the set of matched elements

Function : curCSS

Internal function

Function : swap

Internal function

Code : visible and hidden filters

Section : AJAX

Properties : Regular expressions

Extend : Loading and saving

Function : load

Load data from the server and place the returned HTML into the matched element

Function : serialize

Encode a set of form elements as a string for submission

Function : serializeArray

Encode a set of form elements as an array of names and values

Code : attach ajax functions

Extend : AJAX

Function : get

Retrieve the DOM elements matched by the jQuery object

Function : getScript

Internal function

Function : getJSON

Internal function

Function : post

Load data from the server using a HTTP POST request

Function : ajaxSetup

Set default values for future Ajax requests

Function : ajaxSettings

Internal function

Object : lastModified

Object : etag

Function : ajax

Perform an asynchronous HTTP (Ajax) request

Function : handleError

Internal function

Properties : active

Function : httpSuccess

Determines if an XMLHttpRequest was successful or not

Function : httpNotModified

Determines if an XMLHttpRequest returns NotModified

Function : httpData

Internal function

Function : param

Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request

Section : Effects

Properties : Regular expressions and attributes

Extend : Effects

Function : show

Display the matched elements

Function : hide

Hide the matched elements

Function : toggle

Bind two or more handlers to the matched elements, to be executed on alternate clicks

Function : fadeTo

Adjust the opacity of the matched elements

Function : animate

Perform a custom animation of a set of CSS properties

Function : stop

Stop the currently-running animation on the matched elements

Code : Generate shortcuts for custom animations

Extend : Animation utility functions

Function : speed

Internal function

FUNCTIONS : linear & swing

Internal function

Properties : timers

Function : fx

Internal function

Object : jQuery.fx.prototype

Function : update

Internal function

Function : cur

Internal function

Function : custom

Internal function

Function : show

Internal function

Function : hide

Internal function

Function : step

Internal function

Extend : jQuery.fx

Function : tick

Internal function

Function : stop

Internal function

Object : speeds

Function : opacity

Internal function

Code : jQuery.expr.filters.animated

Function : genFx

Internal function

Section : Dimensions

Code : top, left, offset, etc

Object : offset

Function : initialize

Internal function

Function : bodyOffset

Internal function

Function : setOffset

Internal function

Extend : dimensions

Description

Function : position

Get the current coordinates of the first element in the set of matched elements, relative to the offset parent

Function : offsetParent

Get the closest ancestor element that is positioned

Code : Create scrollLeft and scrollTop methods

Function : getWindow

Internal function

Code : Create innerHeight, innerWidth, outerHeight and outerWidth methods

Properties : Assign jQuery object to window

})(window);