JQuery
Encyclopedia
jQuery is a cross-browser
Cross-browser
Cross-browser refers to the ability for a website, web application, HTML construct or client-side script to support all the web browsers. The term cross-browser is often confused with multi-browser...

 JavaScript library
JavaScript library
A JavaScript library is a library of pre-written JavaScript which allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies....

 designed to simplify the client-side scripting
Client-side scripting
Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side...

 of HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

. It was released in January 2006 at BarCamp
BarCamp
BarCamp is an international network of user-generated conferences . They are open, participatory workshop-events, the content of which is provided by participants. The first BarCamps focused on early-stage web applications, and were related to open source technologies, social protocols, and open...

 NYC by John Resig
John Resig
John Resig is an application developer at Khan Academy. He was a JavaScript tool developer for the Mozilla Corporation. He is also the creator and lead developer of the jQuery JavaScript library. This library's goal is to simplify the process of writing cross-browser JavaScript code...

. Used by over 49% of the 10,000 most visited websites, jQuery is the most popular JavaScript library
JavaScript library
A JavaScript library is a library of pre-written JavaScript which allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies....

 in use today.

jQuery is free, open source software
Free and open source software
Free and open-source software or free/libre/open-source software is software that is liberally licensed to grant users the right to use, study, change, and improve its design through the availability of its source code...

, dual-licensed under the MIT License
MIT License
The MIT License is a free software license originating at the Massachusetts Institute of Technology . It is a permissive license, meaning that it permits reuse within proprietary software provided all copies of the licensed software include a copy of the MIT License terms...

 or the GNU General Public License, Version 2. jQuery's syntax is designed to make it easier to navigate a document, select DOM
Document Object Model
The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...

 elements, create animation
Animation
Animation is the rapid display of a sequence of images of 2-D or 3-D artwork or model positions in order to create an illusion of movement. The effect is an optical illusion of motion due to the phenomenon of persistence of vision, and can be created and demonstrated in several ways...

s, handle events
Event (computing)
In computing an event is an action that is usually initiated outside the scope of a program and that is handled by a piece of code inside the program. Typically events are handled synchronous with the program flow, that is, the program has one or more dedicated places where events are handled...

, and develop Ajax applications
Ajax (programming)
Ajax is a group of interrelated web development methods used on the client-side to create asynchronous web applications...

. jQuery also provides capabilities for developers to create plug-ins on top of the JavaScript library. This enables developers to create abstractions
Abstraction (computer science)
In computer science, abstraction is the process by which data and programs are defined with a representation similar to its pictorial meaning as rooted in the more complex realm of human life and language with their higher need of summarization and categorization , while hiding away the...

 for low-level interaction and animation, advanced effects and high-level, theme-able widgets. The modular approach to the jQuery framework allows the creation of powerful and dynamic web page
Dynamic web page
A dynamic web page is a kind of web page that has been prepared with fresh information , for each individual viewing. It is not static because it changes with the time , the user , the user interaction , the context A dynamic web page is a kind of web page that has been prepared with fresh...

s and web applications.

Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 and Nokia
Nokia
Nokia Corporation is a Finnish multinational communications corporation that is headquartered in Keilaniemi, Espoo, a city neighbouring Finland's capital Helsinki...

 have announced plans to bundle jQuery on their platforms, Microsoft is adopting it initially within Visual Studio for use within Microsoft's ASP.NET AJAX framework and ASP.NET MVC Framework
ASP.NET MVC Framework
The ASP.NET MVC Framework is a web application framework that implements the model-view-controller pattern. Based on ASP.NET, it allows software developers to build a Web application as a composition of three roles: Model, View and Controller. A model represents the state of a particular aspect of...

 while Nokia has integrated it into their Web Run-Time widget development platform. jQuery has also been used in MediaWiki
MediaWiki
MediaWiki is a popular free web-based wiki software application. Developed by the Wikimedia Foundation, it is used to run all of its projects, including Wikipedia, Wiktionary and Wikinews. Numerous other wikis around the world also use it to power their websites...

 since version 1.16.

Etymology

The use of the name jQuery is somewhat misleading, as the library has little to do with queries.
Shortly after its release in January 2006, author John Resig stated, "I was, originally, going to use JSelect, but all the domain names were taken already."

Features

jQuery contains the following features:
  • DOM
    Document Object Model
    The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...

     element selections using the cross-browser open source selector engine Sizzle, a spin-off out of the jQuery project
  • DOM traversal and modification (including support for CSS 1-3)
  • Events
  • CSS
    Cascading Style Sheets
    Cascading Style Sheets is a style sheet language used to describe the presentation semantics of a document written in a markup language...

     manipulation
  • Effects and animations
  • Ajax
    Ajax (programming)
    Ajax is a group of interrelated web development methods used on the client-side to create asynchronous web applications...

  • Extensibility
    Extensibility
    In software engineering, extensibility is a system design principle where the implementation takes into consideration future growth. It is a systemic measure of the ability to extend a system and the level of effort required to implement the extension...

     through plug-ins
  • Utilities - such as user agent information, feature detection
  • Compatibility methods that are natively available in modern browsers but need fallbacks for older ones - For example the inArray and each functions.
  • Cross-browser support

Including the library

The jQuery library is a single JavaScript file, containing all of its common DOM, event, effects, and Ajax functions. It can be included within a web page by linking to a local copy, or to one of the many copies available from public servers. jQuery has a CDN
Content Delivery Network
A content delivery network or content distribution network is a system of computers containing copies of data placed at various nodes of a network....

 sponsored by Media Temple
Media Temple
Media Temple is a website hosting and software application services company based in Culver City, California, USA. It is a pioneer of "grid hosting", whereby multiple stand-alone servers are linked to provide additional capacity for clients during periods of peak demand...

 (previously at Amazon). Google and Microsoft host it as well.





The most popular and basic way to introduce a jQuery function is to use the .ready function.


$(document).ready(function {
// jquery goes here
});

or the shortcut

$(function {
// jquery goes here
});

Usage styles

jQuery has two usage styles:
  • via the $ function, which is a factory method
    Factory method pattern
    The factory method pattern is an object-oriented design pattern to implement the concept of factories. Like other creational patterns, it deals with the problem of creating objects without specifying the exact class of object that will be created.The creation of an object often requires complex...

     for the jQuery object. These functions, often called commands, are chainable
    Method chaining
    Method chaining is a common technique for invoking multiple method calls in object-oriented programming languages. Each method returns an object , allowing the calls to be chained together in a single statement...

    ; they all return jQuery objects
  • via $.-prefixed functions. These are utility functions which do not work on the jQuery object per se.


Typically, access to and manipulation of multiple DOM nodes begins with the $ function being called with a CSS
CSS
-Computing:*Cascading Style Sheets, a language used to describe the style of document presentations in web development*Central Structure Store in the PHIGS 3D API*Closed source software, software that is not distributed with source code...

 selector string, which results in a jQuery object referencing matching elements in the HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

 page. This node set can be manipulated by calling instance methods on the jQuery object, or on the nodes themselves. For example:

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

This line finds the union of all div tags with class attribute test and all p tags with CSS class attribute quote, adds the class attribute 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 following script automatically checks whether the jQuery file is included. If not, it appends a jquery reference to the head section

if(!(window.jQuery && window.jQuery.fn.jquery '1.6.2')) {
var s = document.createElement('script');
s.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js');
s.setAttribute('type', 'text/javascript');
document.getElementsByTagName('head')[0].appendChild(s);
}


The methods prefixed with $. are convenience methods or affect global properties and behaviour. For example, the following is an example of the map function
Map (higher-order function)
In many programming languages, map is the name of a higher-order function that applies a given function to each element of a list, returning a list of results. They are examples of both catamorphisms and anamorphisms...

 called each in jQuery:

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

This writes "234" to the document.

It is possible to perform browser-independent Ajax
Ajax (programming)
Ajax is a group of interrelated web development methods used on the client-side to create asynchronous web applications...

 queries using $.ajax and associated methods to load and manipulate remote data.

$.ajax({
type: "POST",
url: "example.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});

This example posts the data name=John and location=Boston to example.php on the server. When this request finishes successfully, the success function is called to alert the user.
jQuery plug-ins
Because of jQuery's architecture, other developers can use its constructs to create plug-in code to extend its functionality. Currently there are thousands of jQuery plug-ins available on the web that cover a wide range of functionality such as Ajax helpers, webservices, datagrids, dynamic lists, XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

 and XSLT
XSLT
XSLT is a declarative, XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized by the processor in standard XML syntax or in another format,...

 tools, drag and drop, events, cookie
HTTP cookie
A cookie, also known as an HTTP cookie, web cookie, or browser cookie, is used for an origin website to send state information to a user's browser and for the browser to return the state information to the origin site...

 handling, modal window
Modal window
In user interface design, a modal window is a child window that requires users to interact with it before they can return to operating the parent application, thus preventing the workflow on the application main window...

s, even a jQuery-based Commodore 64
Commodore 64
The Commodore 64 is an 8-bit home computer introduced by Commodore International in January 1982.Volume production started in the spring of 1982, with machines being released on to the market in August at a price of US$595...

 emulator.

An important source of jQuery plug-ins is the Plugins sub-domain of the jQuery Project website. There are alternative plug-in search engines that take more specialist approaches, such as only listing plug-ins that meet certain criteria (e.g. those that have a public code repository). The tutorials page on the jQuery site has a list of links to jQuery plug-in tutorials under the "Plugin development" section.
Release history
Version number Release date Additional notes
1.0 August 26, 2006 First stable release
1.0.1 August 31, 2006
1.0.2 October 9, 2006
1.0.3 October 27, 2006
1.0.4 December 12, 2006 Last 1.0 bug fix
1.1 January 14, 2007
1.1.1 January 22, 2007
1.1.2 February 27, 2007
1.1.3 July 1, 2007
1.1.3.1 July 5, 2007
1.1.4 August 24, 2007
1.2 September 10, 2007
1.2.1 September 16, 2007
1.2.2 January 15, 2008
1.2.3 February 8, 2008
1.2.4 May 19, 2008
1.2.5 May 21, 2008 Fix for bad build of 1.2.4
1.2.6 May 24, 2008
1.3 January 14, 2009 Sizzle Selector Engine introduced into core
1.3.1 January 21, 2009
1.3.2 February 20, 2009
1.4 January 14, 2010
1.4.1 January 25, 2010
1.4.2 February 19, 2010
1.4.3 October 16, 2010
1.4.4 November 11, 2010
1.5 January 31, 2011 Deferred callback management, ajax module rewrite
1.5.1 February 24, 2011
1.5.2 March 31, 2011
1.6 May 3, 2011 Significant performance improvements to the attr and val functions
1.6.1 May 12, 2011
1.6.2 June 30, 2011
1.6.3 September 1, 2011
1.6.4 September 12, 2011
1.7 November 3, 2011 New Event APIs: .on and .off, while the old APIs are still supported.
1.7.1 November 21, 2011

Testing framework


QUnit is a test automation framework
Test automation framework
A test automation framework is a set of assumptions, concepts and tools that provide support for automated software testing. The main advantage of such a framework is the low cost for maintenance. If there is change to any test case then only the test case file needs to be updated and the Driver...

 used to test the jQuery project. It was developed by the jQuery team as an in-house unit testing library.

As of 2011 QUnit is used in conjunction with TestSwarm in order to test each release of the jQuery codebase.

See also


  • Comparison of JavaScript frameworks
    Comparison of JavaScript frameworks
    - Rationale :There are many JavaScript frameworks available. The intention of this comparison is to show some examples of JavaScript frameworks with their different features.- Table of Javascript Frameworks :- External links :* * * * * * * *...

  • jQuery UI
    JQuery UI
    jQuery UI is a JavaScript library that provides abstractions for low-level interaction and animation, advanced effects and high-level, themeable widgets, built on top of the jQuery JavaScript library, that can be used to build interactive web applications. It was released in September 2007...

  • jQuery Mobile
    JQuery Mobile
    jQuery Mobile is a touch-optimized web framework currently being developed by the jQuery project team. The development focuses on creating a framework compatible with a wide variety of smartphones and tablets, made necessary by the growing-but-heterogenous tablet and smartphone market...


External links
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK