No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

README.md 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # jQuery
  2. > jQuery is a fast, small, and feature-rich JavaScript library.
  3. For information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/).
  4. For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).
  5. ## Including jQuery
  6. Below are some of the most common ways to include jQuery.
  7. ### Browser
  8. #### Script tag
  9. ```html
  10. <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
  11. ```
  12. #### Babel
  13. [Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively.
  14. ```js
  15. import $ from "jquery";
  16. ```
  17. #### Browserify/Webpack
  18. There are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this...
  19. ```js
  20. var $ = require("jquery");
  21. ```
  22. #### AMD (Asynchronous Module Definition)
  23. AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html).
  24. ```js
  25. define(["jquery"], function($) {
  26. });
  27. ```
  28. ### Node
  29. To include jQuery in [Node](nodejs.org), first install with npm.
  30. ```sh
  31. npm install jquery
  32. ```
  33. For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes.
  34. ```js
  35. require("jsdom").env("", function(err, window) {
  36. if (err) {
  37. console.error(err);
  38. return;
  39. }
  40. var $ = require("jquery")(window);
  41. });
  42. ```