jQuery Get Started
In this tutorial, we shall learn how to get started with using jQuery in HTML pages.
Get jQuery Script file
There are two ways to get jQuery Script file.
1. Download jQuery and upload to web server
Download it from http://jquery.com/, upload it to your web server and include it in the HTML.
Say you uploaded jquery-3.3.1.min.js at the root location of your web server, then include the following line in the head or anywhere before you use the jQuery.
<head> <script src="jquery-3.3.1.min.js"></script> </head>
2. Use jQuery hosted on CDN by Google or Microsoft. (Recommended)
CDN is a network of servers hosted at many geographical locations. When a request is made for a resource hosted at CDN, the request is served from the nearest server resulting in faster loading times.
This is the recommended way, since time for downloading a file from CDN is fast. Also considering the fact that most of the websites use jQuery, your web-browser may use the jQuery from cache, making the page load fast.
Using Google CDN
<head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </head>
Using Microsoft CDN
<head> <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script> </head>