Preliminary understanding of JavaScript function library jQuery

  • 2020-06-19 09:37:55
  • OfStack

The jQuery library can be added to a web page with a simple 1-line tag.
jQuery library - Features

jQuery is an JavaScript library.

The jQuery library contains the following features:

HTML element selection HTML element operations CSS operation HTML event function JavaScript effects and animation HTML DOM traversal and modification AJAX Utilities

Add the jQuery library to your page

The jQuery library is located in an JavaScript file that contains all of the jQuery functions.

You can add jQuery to a web page with the following tags:


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

Please note that, < script > The tag should be on the page < head > Part.
Base jQuery instance

The following example demonstrates the hide() function of jQuery, hiding all of the HTML documents < p > Elements.
The instance


<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: one is condensed and the other is uncompressed (for debugging or reading).

Both versions are available for download from ES61en.com.
Library of alternative

Both Google and Microsoft support jQuery very well.

If you do not want to store the jQuery library on your computer, you can load the CDN jQuery core file from Google or Microsoft.
CDN using Google


<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs
/jquery/1.4.0/jquery.min.js"></script>
</head>

Use CDN of Microsoft


<head>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
</head>



Related articles: