Home >Web Front-end >JS Tutorial >A preliminary understanding of the JavaScript function library jQuery_jquery
The jQuery library can be added to a web page with a simple line of markup.
jQuery Library - Features
jQuery is a JavaScript function library.
The jQuery library includes the following features:
Add the jQuery library to your page
The jQuery library is located in a JavaScript file that contains all jQuery functions.
jQuery can be added to a web page through the following tag:
<head> <script type="text/javascript" src="jquery.js"></script> </head>
Please note that the 3f1c4e4b6b16bbbd69b2ee476dc4f83a tag should be in the 93f0f5c25f18dab9d176bd4f6de5d30e section of the page.
Basic jQuery Example
The following example demonstrates jQuery's hide() function, hiding all e388a4556c0f65e1904146cc1a846bee elements in an HTML document.
Example
<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button type="button">Click me</button> </body> </html>
Try it for yourself
Download jQuery
There are two versions of jQuery available for download: a minified version and an uncompressed version (for debugging or reading).
Both versions are available for download from jQuery.com.
Library replacement
Both Google and Microsoft have great support for jQuery.
If you don't want to host the jQuery library on your computer, you can load the CDN jQuery core files from Google or Microsoft.
Use Google’s CDN
<head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs /jquery/1.4.0/jquery.min.js"></script> </head>
Use Microsoft’s CDN
<head> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery /jquery-1.4.min.js"></script> </head>