Where To Put jQuery In HTML?
How To Include jQuery In HTML?
Including jQuery to HTML is one of the easiest tasks. It is very simple to include jQuery into the HTML page within just a few lines of code and hence it is widely used by web developers.
There are two methods to include jQuery to your HTML.
- You can download and include the jQuery file
- You can include the jQuery by CDN.
- Download and include jQuery file
In this method, you have to download the jQuery js file and include it using a simple <script > tag within your HTML code. It is very easy for any user to add jQuery to Html within just a few steps. If you want to include the jQuery to your HTML page by downloading the jQuery file, simply follow the steps given below.
1: You have to download the jquery js file from the official site of jQuery.
Step 2: After downloading the file you have to open the Html file in which you want to add your jQuery. In your HTML code have to use the <script> tag, which specifies the src attribute for adding the jQuery file between the head tag just and the title tag as shown below:
Step 3: And finally save your HTML file and you can see that the jQuery file is successfully added into our Html page.
Let's understand with an example:
Here's what the output will be:
2. Including the jQuery by CDN.
Another method to include your jQuery to Html is including the jQuery by CDN(Content Delivery Network). It is very easy to implement by using CDN using the following steps.
Step 1: Open the HTML file in which you want to add your jQuery with the help of CDN.
Step 2: Add <script> tag between the head tag and the title tag which will specify the src attribute for adding your jQuery.
Step 3: After that, you have to add the following path in the src attribute of the script tag.
Step 4: Save your HTML file and your jQuery is successfully added.
Let's see how this is done:
To keep learning such interesting topics, subscribe to our blog!
To know more about what is jQuery used for, visit our previous article!