JQuery

From Wikipedia, the free encyclopedia

The correct title of this article is jQuery. The initial letter is shown capitalized due to technical restrictions.
jQuery JavaScript Library
Developer: John Resig
Latest release: 1.1.2 / February 28, 2007
Use: JavaScript Framework
License: MIT License, GPL
Website: jquery.com

jQuery is a lightweight JavaScript framework that emphasizes the interaction between JavaScript and HTML. It was released January 2006 at BarCamp NYC by John Resig.

Contents

[edit] Features

The jQuery JavaScript library contains the following features:

  • DOM traversal and modification (including support for CSS 1-3 and basic XPath)
  • Events
  • Effects and animations
  • Ajax
  • Extensibility

[edit] Usage

jQuery exists as a single JavaScript file, containing all the common DOM, Event, Effects, and Ajax functions. It can be included within any web page by using the following code:

 <script src="path/to/jQuery.js"></script>

jQuery has two styles of interaction:

  • via the $ function, which is a factory method for the jQuery object. These functions are chainable; they each return the jQuery object
  • via $.-prefixed functions. These are functions which do not work in the jQuery object per se.

A typical workflow for manipulation of multiple DOM nodes begins with $ function being called with a CSS selector string, with results in the jQuery object referencing zero or more elements in the HTML page. This node set can be manipulated by applying instance methods to the jQuery object, or the nodes themselves can be manipulated. For example:

$("div.test").add("p.quote").addClass("blue").slideDown("slow");

finds the union of all div tags with class test and all p tags with class quote, adds the CSS class blue to each matched element, and then slides them down with an animation. The $ and add functions affect the matched set, while the addClass and slideDown affect the referenced nodes.

The methods prefixed with $. are convenience methods or affect global properties and behaviour. For example,

$.each([1,2,3], function() {
  document.write(this + 1);
});

Will write

234

to the document. It is possible to perform Ajax routines using the $.ajax and associated methods to load and manipulate remote data.

[edit] Resources

[edit] Notable users of jQuery

[edit] jQuery in the Media

[edit] Books that talk about jQuery

In other languages