Jump to content

JQuery: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Bobbravo2 (talk | contribs)
m Made intro paragraph clearer
Line 20: Line 20:
'''jQuery''' is a [[cross-browser]] [[JavaScript library]] designed to simplify the [[client-side scripting]] of [[HTML]].<ref name="jquery.com">{{cite web|url=http://jquery.com/|title=jQuery: The write less, do more, JavaScript library|publisher=The jQuery Project|accessdate=29 April 2010}}</ref> It was released in January 2006 at [[BarCamp]] NYC by [[John Resig]]. Used by over 43% of the 10,000 most visited websites, jQuery is the most popular [[JavaScript library]] in use today.<ref>{{cite web |url=http://trends.builtwith.com/javascript/JQuery |title=jQuery Usage Statistics}}</ref><ref>{{cite web |url=http://w3techs.com/technologies/overview/javascript_library/all|title=Usage of JavaScript libraries for websites|publisher=W3Techs|accessdate=2010-07-08}}</ref>
'''jQuery''' is a [[cross-browser]] [[JavaScript library]] designed to simplify the [[client-side scripting]] of [[HTML]].<ref name="jquery.com">{{cite web|url=http://jquery.com/|title=jQuery: The write less, do more, JavaScript library|publisher=The jQuery Project|accessdate=29 April 2010}}</ref> It was released in January 2006 at [[BarCamp]] NYC by [[John Resig]]. Used by over 43% of the 10,000 most visited websites, jQuery is the most popular [[JavaScript library]] in use today.<ref>{{cite web |url=http://trends.builtwith.com/javascript/JQuery |title=jQuery Usage Statistics}}</ref><ref>{{cite web |url=http://w3techs.com/technologies/overview/javascript_library/all|title=Usage of JavaScript libraries for websites|publisher=W3Techs|accessdate=2010-07-08}}</ref>


jQuery is [[free and open source software|free, open source software]], [[Dual-licensing|dual-licensed]] under the [[MIT License]] and the [[GNU General Public License#Version 2|GNU General Public License, Version 2]].<ref>{{cite web |url=http://docs.jquery.com/License |title=License – JQuery JavaScript Library |accessdate=2009-11-26}}</ref> jQuery's syntax is designed to make it easier to navigate a document, select [[Document Object Model|DOM]] elements, create [[animation]]s, handle [[Event (computing)|events]], and develop [[Ajax (programming)|Ajax applications]]. jQuery also provides capabilities for developers to create [[Plug-in (computing)|plug-in]]s on top of the JavaScript library. Using these facilities, developers are able to create [[Abstraction (computer science)|abstractions]] for low-level interaction and animation, advanced effects and high-level, theme-able widgets. This contributes to the creation of powerful and dynamic web pages.
jQuery is [[free and open source software|free, open source software]], [[Dual-licensing|dual-licensed]] under the [[MIT License]] and the [[GNU General Public License#Version 2|GNU General Public License, Version 2]].<ref>{{cite web |url=http://docs.jquery.com/License |title=License – JQuery JavaScript Library |accessdate=2009-11-26}}</ref> jQuery's syntax is designed to make it easier to navigate a document, select [[Document Object Model|DOM]] elements, create [[animation]]s, handle [[Event (computing)|events]], and develop [[Ajax (programming)|Ajax applications]]. jQuery also provides capabilities for developers to create [[Plug-in (computing)|plug-in]]s on top of the JavaScript library. This enables developers to create [[Abstraction (computer science)|abstractions]] for low-level interaction and animation, advanced effects and high-level, theme-able widgets. This contributes to the creation of powerful and dynamic web pages.


[[Microsoft]] and [[Nokia]] have announced plans to bundle jQuery on their platforms,<ref name="2008-09-28">{{cite web |url=http://jquery.com/blog/2008/09/28/jquery-microsoft-nokia/ |title=jQuery, Microsoft, and Nokia |date=2008-09-28 |last=Resig |first=John |publisher=jQuery |work=jQuery Blog |accessdate=2009-01-29 }}</ref> Microsoft is adopting it initially within [[Visual Studio]]<ref>{{cite web |url=http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx |title=jQuery and Microsoft |last=Guthrie |first=Scott |work=ScottGu's Blog |date=2008-09-28 |accessdate=2009-01-29 }}</ref> for use within Microsoft's [[ASP.NET AJAX]] framework and [[ASP.NET MVC Framework]] while Nokia has integrated it into their Web Run-Time widget development platform.<ref>{{cite web |url=http://wiki.forum.nokia.com/index.php/Guarana_UI:_a_jQuery-Based_UI_Library_for_Nokia_WRT |title=Guarana UI: A jQuery Based UI Library for Nokia WRT |accessdate=2010-03-30 |work=Forum Nokia}}</ref> jQuery has also been used in [[MediaWiki]] since version 1.16.<ref>http://www.mediawiki.org/wiki/JQuery</ref>
[[Microsoft]] and [[Nokia]] have announced plans to bundle jQuery on their platforms,<ref name="2008-09-28">{{cite web |url=http://jquery.com/blog/2008/09/28/jquery-microsoft-nokia/ |title=jQuery, Microsoft, and Nokia |date=2008-09-28 |last=Resig |first=John |publisher=jQuery |work=jQuery Blog |accessdate=2009-01-29 }}</ref> Microsoft is adopting it initially within [[Visual Studio]]<ref>{{cite web |url=http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx |title=jQuery and Microsoft |last=Guthrie |first=Scott |work=ScottGu's Blog |date=2008-09-28 |accessdate=2009-01-29 }}</ref> for use within Microsoft's [[ASP.NET AJAX]] framework and [[ASP.NET MVC Framework]] while Nokia has integrated it into their Web Run-Time widget development platform.<ref>{{cite web |url=http://wiki.forum.nokia.com/index.php/Guarana_UI:_a_jQuery-Based_UI_Library_for_Nokia_WRT |title=Guarana UI: A jQuery Based UI Library for Nokia WRT |accessdate=2010-03-30 |work=Forum Nokia}}</ref> jQuery has also been used in [[MediaWiki]] since version 1.16.<ref>http://www.mediawiki.org/wiki/JQuery</ref>

Revision as of 03:54, 23 June 2011

jQuery
Original author(s)John Resig
Developer(s)jQuery Team
Initial releaseAugust 26, 2006 (2006-08-26)
Stable release
1.6.1 / May 12, 2011 (2011-05-12)
Repository
Written inJavaScript
Size31 KB zipped / 84 KB (production mode) / 227 KB (development mode)
TypeWeb application framework
LicenseDual license:
GPL or MIT
Websitejquery.com

jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML.[1] It was released in January 2006 at BarCamp NYC by John Resig. Used by over 43% of the 10,000 most visited websites, jQuery is the most popular JavaScript library in use today.[2][3]

jQuery is free, open source software, dual-licensed under the MIT License and the GNU General Public License, Version 2.[4] jQuery's syntax is designed to make it easier to navigate a document, select DOM elements, create animations, handle events, and develop Ajax applications. jQuery also provides capabilities for developers to create plug-ins on top of the JavaScript library. This enables developers to create abstractions for low-level interaction and animation, advanced effects and high-level, theme-able widgets. This contributes to the creation of powerful and dynamic web pages.

Microsoft and Nokia have announced plans to bundle jQuery on their platforms,[5] Microsoft is adopting it initially within Visual Studio[6] for use within Microsoft's ASP.NET AJAX framework and ASP.NET MVC Framework while Nokia has integrated it into their Web Run-Time widget development platform.[7] jQuery has also been used in MediaWiki since version 1.16.[8]

Features

jQuery contains the following features:

  • DOM element selections using the cross-browser open source selector engine Sizzle, a spin-off out of the jQuery project[9]
  • DOM traversal and modification (including support for CSS 1-3)
  • Events
  • CSS manipulation
  • Effects and animations
  • Ajax
  • Extensibility through plug-ins
  • Utilities - such as browser version and the each function.
  • 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 (such as Google [10] or Microsoft CDN).

<script type="text/javascript" src="jquery.js"></script>

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 for the jQuery object. These functions, often called commands, are chainable; 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 selector string, which results in a jQuery object referencing matching elements in the HTML 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.4.4')) {
  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 called each in jQuery:

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

This writes the number 234 to the document.

It is possible to perform browser-independent Ajax 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[11] that cover a wide range of functionality such as Ajax helpers, webservices, datagrids, dynamic lists, XML and XSLT tools, drag and drop, events, cookie handling, modal windows, even a jQuery-based Commodore 64 emulator.[12]

An important source of jQuery plug-ins is the Plugins sub-domain of the jQuery Project website.[11] There are alternative plug-in search engines[13] 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.[14]

Etymology

The use of the name jQuery is somewhat fanciful, 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."[15]

Release history

Release date Version number Additional notes
August 26, 2006 1.0 First stable release
August 31, 2006 1.0.1
October 9, 2006 1.0.2
October 27, 2006 1.0.3
December 12, 2006 1.0.4 Last 1.0 bug fix
January 14, 2007 1.1
January 22, 2007 1.1.1
February 27, 2007 1.1.2
July 1, 2007 1.1.3
July 5, 2007 1.1.3.1
August 24, 2007 1.1.4
September 10, 2007 1.2
September 16, 2007 1.2.1
January 15, 2008 1.2.2
February 8, 2008 1.2.3
May 19, 2008 1.2.4
May 21, 2008 1.2.5 Fix for bad build of 1.2.4
May 24, 2008 1.2.6
January 14, 2009 1.3 Sizzle Selector Engine introduced into core
January 21, 2009 1.3.1
February 20, 2009 1.3.2
January 14, 2010 1.4
January 25, 2010 1.4.1
February 19, 2010 1.4.2
October 16, 2010 1.4.3
November 11, 2010 1.4.4
January 31, 2011 1.5 Deferred callback management
February 24, 2011 1.5.1
March 31, 2011 1.5.2
May 3, 2011 1.6 Significant performance improvements to the attr() and val() functions
May 12, 2011 1.6.1

See also

References

  1. ^ "jQuery: The write less, do more, JavaScript library". The jQuery Project. Retrieved 29 April 2010.
  2. ^ "jQuery Usage Statistics".
  3. ^ "Usage of JavaScript libraries for websites". W3Techs. Retrieved 2010-07-08.
  4. ^ "License – JQuery JavaScript Library". Retrieved 2009-11-26.
  5. ^ Resig, John (2008-09-28). "jQuery, Microsoft, and Nokia". jQuery Blog. jQuery. Retrieved 2009-01-29.
  6. ^ Guthrie, Scott (2008-09-28). "jQuery and Microsoft". ScottGu's Blog. Retrieved 2009-01-29.
  7. ^ "Guarana UI: A jQuery Based UI Library for Nokia WRT". Forum Nokia. Retrieved 2010-03-30.
  8. ^ http://www.mediawiki.org/wiki/JQuery
  9. ^ Resig, John (2009-01-14). "jQuery 1.3 and the jQuery Foundation". jQuery Blog. Retrieved 2009-05-04.
  10. ^ http://code.google.com/apis/ajaxlibs/documentation/#jquery
  11. ^ a b "Plugins". The jQuery Project. Retrieved 26 August 2010.
  12. ^ "JavaScript Commodore Emulator". Kingsquare. Retrieved 26 August 2010.
  13. ^ "pluginquery". Appleton Webb Ltd. Retrieved 26 August 2010.
  14. ^ "Tutorials". The jQuery Project. Retrieved 26 August 2010.
  15. ^ "BarCampNYC Wrap-up". John Resig. Retrieved 27 May 2011.(click on the "Show Comments" link at the bottom of the cited page)

Further reading