jQuery

JQuery (also: jQuery Core ) is a free JavaScript library which provides functions for DOM navigation and manipulation. Developed by John Resig library was published in January 2006 on the BarCamp ( NYC) in New York and is continually evolving.

Currently maintained with 1.x and 2.x version two independent strands that differ in terms of browser compatibility. The 1.x versions (from 1.9) and 2.x have a compatible API.

Dissemination

JQuery is the most widely used JavaScript library. Every other site and two-thirds of the 10,000 most visited websites use jQuery (as of August 2013).

JQuery 2.0

Since the release of the alpha version 1.0 in June 2006, the framework retained the major version first appeared in April 2013 jQuery 2.0.

Due to better JavaScript support modern web browser ( for example, access to DOM nodes ) was the source of jQuery 2.0 will fundamentally restructured and cleaned up. To this end, support for older browsers, such as Internet Explorer up to version 8 (and the compatibility view in more recent versions ) away. Because these browsers still have some high use numbers, will continue waiting for the 1.x version line for compatibility and updated. In order for the 1.x version line is not replaced entirely, but developed in parallel.

Functions

  • Element selection in the Document Object Model of the Sizzle selector engine, which largely corresponds to the CSS 3 selectors
  • Document Object Model Manipulation
  • Advanced Event System
  • Auxiliary functions such as the each function
  • Animations and Effects
  • Ajax functionality
  • Extensibility through numerous free plug-ins, such as jQuery UI for the uniform design of user interfaces

Use

After the file, the framework contained in the HTML document is involved, jQuery can be used. Typically generated by access to objects with the $ function or to go to compatibility issues with other libraries out of the way and achieve a better readability, the jQuery function an object. This jQuery object can be thanks to Fluent interfaces passed to other functions.

In order to with several libraries that use the $ character as a call to work, you can disable this in jQuery:

/ / Returns the $ sign to other libraries free ( can also be accessed using the $ notation) jQuery.noConflict (); A typical manipulation of DOM elements begins with the $ - or jQuery function that expects as parameters a CSS -like selector. Returned then matching DOM elements, which can then be manipulated using jQuery methods. example:

$ (" div.test, p.quote " ) addClass ( " blue" ) slideup ( " slow"). .; / / Or even jQuery ( " div.test, p.quote " ) addClass ( " blue" ) slideup ( " slow"). .; In this example, all div elements are tested with the class and selects all p elements with the quote class. Then each of the elements found the CSS class blue is added. Finally, the selected elements in the context of animation " pushed up " ( What makes the objects disappear ).

In addition, there are global helper functions. These can be invoked using the $ -/jQuery-Funktion. The following example script the each function demonstrates:

Var myArray = [1, 2, 3]; $. each ( myArray, function () {    document.write (this 1); }); This example writes 234 into the document.

Ajax functionality can be called ajax using $. . In the example below an asynchronous HTTP POST done - request to a PHP script. If the call is successful, the response from the PHP script is issued with a warning window.

$. ajax ({    type: "POST",    url: " example.php "    data: "name = Doe & location = Berlin "    success: function ( response) {      alert ( "Data Saved :" response);    } }); With the help of jQuery DOM elements can also actions (english events) are added:

$ (document). ready (function () {    $ (" div.test a"). on ( ' click', function () {      alert (" Hello world! ");    }); }); In this example assigns ( within div elements with the class "test") an event listener after loading the DOM tree each "a " element, which outputs a message when Thereupon click. The advantage of this implementation is that the behavior can be controlled at a central location.

Designation

Originally the library jSelect should be called. Since the domain was already taken for that name, developers John Resig chose the name jQuery.

de