jQuery

from Wikipedia, the free encyclopedia
jQuery

Logo from jQuery
Basic data

developer jQuery team
Publishing year August 2005
Current  version 3.5.1
( May 4, 2020 )
operating system platform independent
programming language JavaScript
category Library
License WITH
jquery.com

jQuery (also jQuery Core ) is a free JavaScript - library that functions for DOM Navigation and manipulation provides.

jQuery is the most widely used JavaScript library. Every second website and 70% of the 10,000 most visited websites use jQuery (as of January 2018). jQuery is already included in many content management systems and web frameworks, for example in Joomla , WordPress , MediaWiki or Drupal .

history

Originally the library was supposed to be named jSelect . Since the domain for this name was already taken, developer John Resig decided on the name jQuery. The library developed by John Resig was published in January 2006 at Barcamp (NYC) in New York. In the meantime, the jQuery library is being continuously developed by the independent jQuery Foundation and supplemented by further libraries with JQuery UI , jQuery Mobile , Sizzle Selector Engine and QUnit . The inventor John Resig has since withdrawn from active development work and handed it over to the jQuery team, to which he still belongs as an honorary member.

Parallel version strands

Up to 2016, two version strands were maintained, 1.x and 2.x, which differ in terms of browser compatibility. The versions 1.x (from 1.9) and 2.x have a compatible API . A new version strand has been introduced since June 9, 2016 with the release of version 3.0. Most of it is also backwards compatible .

Version 1.x began in June 2006 as version 1.0 as an alpha version . The first version of version 2.x was published in April 2013 under the name " jQuery 2.0 ". Due to better JavaScript support of modern web browsers (for example access to DOM nodes ) the source code of jQuery 2.0 could be fundamentally restructured and cleaned up. In return, support for older browsers such as Internet Explorer up to and including version 8 (and the compatibility view in more recent versions) has been removed. Because these older browsers still have a relatively high number of uses depending on the area of ​​application, the 1.x version line was maintained and updated for reasons of compatibility until version 3.0 was released on June 9, 2016. The version lines 1.x and 2.x will continue to be supplied with security-relevant patches . Version 3.x, however, does not support Internet Explorer- specific features at all. Among other things, the API for was jQuery.deferredchanged with version 3.0 and outdated event listeners , namely .load, .unloadand .error, were removed.

Functions

jQuery offers JavaScript developers the following functions:

  • Element selection in the Document Object Model using the Sizzle Selector Engine , which largely corresponds to the CSS 3 selectors
  • Document-Object-Model manipulation
  • Extended event system
  • Auxiliary functions such as the eachfunction
  • Animations and Effects
  • Ajax functionalities
  • Extensibility through numerous free plug-ins , such as jQuery UI for the uniform design of user interfaces or DataTables for displaying tabular data

use

The jQuery base library consists of a JavaScript file that contains all the basic DOM, events, effects and Ajax functions.

After the file containing the library has been integrated into the HTML document , jQuery can be used. Typically, by accessing objects with the $function or in order to avoid compatibility problems with other libraries and to achieve better readability, jQueryan object is created with the function. This jQuery object can be passed to other functions thanks to fluent interfaces .

In order to be able to work with several libraries that use the $ symbol as a call, this can be deactivated in jQuery:

// gibt das $-Zeichen für andere Bibliotheken frei (kann auch mit der $-Notation aufgerufen werden)
jQuery.noConflict();

A typical manipulation of DOM elements begins with the $or jQueryfunction, which expects a CSS- like selector as a parameter . Matching DOM elements are then returned, which can then be manipulated with jQuery methods. Example:

$("div.test, p.quote")
    .addClass("blue")
    .slideUp("slow");

// oder auch
jQuery("div.test, p.quote")
    .addClass("blue")
    .slideUp("slow");

In this example, all divelements with the class testand all pelements with the class are quoteselected. Then the CSS class is blueadded to each of the found elements . Finally, the vertical collapse of these elements is animated.

There are also global auxiliary functions. These can be called up using the $- / jQueryfunction. The eachfunction is demonstrated in the following example script :

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

This example writes 234in the document.

Ajax functionalities can be called with the help of $.ajax. In the example below, an asynchronous HTTP POST request is made to a PHP script. If the call is successful, the response from the PHP script is displayed with a message window.

$.ajax({
  type: "POST",
  url: "beispiel.php",
  data: "name=Mustermann&location=Berlin",
}).done(function(response){
    alert("Daten gespeichert: " + response);
});

With the help of jQuery, events can also be added to the DOM elements:

$(function() {
  $("div.test a").on('click', function() {
    alert("Hello world!");
  });
});

In this example, after loading the DOM structure div, an event listener is assigned to each “a” element that is located within elements with the class “test” , which outputs a message when the element is clicked. The advantage of this implementation is that the click behavior can be controlled at a central point and is not stored in the HTML element itself.

See also

literature

Web links

Individual evidence

  1. History jquery History and development of jquery.
  2. jQuery 3.5.1 Released: Fixing a Regression . 4th May 2020.
  3. Usage of javascript libraries for websites . Retrieved May 7, 2010.
  4. jQuery now runs on every second website. Retrieved September 3, 2012 .
  5. ^ JQuery Usage Statistics. Websites using jQuery. BuiltWith.com, accessed January 31, 2018 .
  6. Joomla! Documentation - Javascript Frameworks. Retrieved May 14, 2015 .
  7. Use of jQuery in WordPress. Retrieved March 16, 2013 .
  8. jQuery in MediaWiki. Retrieved March 16, 2013 .
  9. Working with JavaScript and jQuery. Drupal, accessed March 16, 2013 .
  10. John Resig: BarCampNYC Wrap-up. January 16, 2006, Retrieved March 16, 2013 (developer John Resig's comment).
  11. See list of team members and status at jquery.org/team (accessed February 16, 2015)
  12. jQuery 1.0 Alpha Release Announcement of the alpha version 1.0 (English), accessed on April 2, 2013.
  13. a b c jQuery 3.0 Final Released! in their own weblog. June 9, 2016, accessed March 11, 2017 .
  14. jQuery 1.10 and 2.0.1: Synchronized features and Cordova fix, accessed on May 27, 2013.
  15. DataTables Table plug-in for jQuery