Here are two distinct methods for integrating jQuery into an HTML page:
- Download and Embed the jQuery file
- Integrate jQuery using a Content Delivery Network (CDN)
Download and Include jQuery File
To incorporate jQuery into an HTML page through downloading the jQuery file, the following steps should be adhered to. By following these instructions, any individual can seamlessly integrate jQuery.
To begin, the initial step involves acquiring the jQuery JavaScript file by downloading it from the official website of jQuery. https://jquery.com/download/
Step 2: After downloading the file, proceed to opening the HTML file where you intend to include jQuery.
<!Doctype Html>
<Html>
<Head>
<Title>
Add the jQuery file into Html by downloading and Including file
</Title>
</Head>
<Body>
Hello User!... <br> <center>
<img src="https://placehold.co/400x300/9b59b6/ffffff?text=Logo" width="100" height="100" > </center>
</Body>
</Html>
Step 3: Next, position the cursor between the opening <head> tag and the <title> tag. Then, insert the <script> element to define the src attribute for including the jQuery file.
<!Doctype Html>
<Html>
<Head>
<script type="text/javascript" src="https://placehold.co/400x300/1abc9c/ffffff?text=Sample+Image">
</script>
<Title>
Add the jQuery file into Html by downloading and Including file
</Title>
</Head>
<Body>
Hello User!... <br> <center>
<img src="https://placehold.co/400x300/9b59b6/ffffff?text=Logo" width="100" height="100" > </center>
</Body>
</Html>
Step 4 involves saving the HTML file after successfully incorporating the jQuery file into our HTML page.
Include the jQuery by CDN
To integrate jQuery into an HTML page via a Content Delivery Network (CDN), it is essential to adhere to the following outlined procedures. By following these steps, users can effortlessly incorporate jQuery.
Step 1: To begin, the first task is to open the HTML file where we intend to incorporate jQuery using a Content Delivery Network (CDN).
<!Doctype Html>
<Html>
<Head>
<Title>
Add the jQuery file into Html by including CDN
</Title>
</Head>
<Body>
Hello User!... <br> <center>
<img src="https://placehold.co/400x300/9b59b6/ffffff?text=Logo" width="100" height="100" > </center>
</Body>
</Html>
Step 2: Following that, we need to position the cursor between the opening head tag and the title tag. Subsequently, we utilize the <script> tag to define the src attribute for inclusion.
<!Doctype Html>
<Html>
<Head>
<script type="text/javascript" src=>
</script>
<Title>
Add the jQuery file into Html by including CDN
</Title>
</Head>
<Body>
Hello User!... <br> <center>
<img src="https://placehold.co/400x300/9b59b6/ffffff?text=Logo" width="100" height="100" > </center>
</Body>
</Html>
Step 3 involves entering the specified path into the src attribute.
http://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
Step 4: Finally, remember to save the HTML file, ensuring that the jQuery file has been successfully integrated into our HTML page.
<!Doctype Html>
<Html>
<Head>
<script type="text/javascript" src="https://placehold.co/400x300/1abc9c/ffffff?text=Sample+Image">
</script>
<Title>
Add the jQuery file into Html by including CDN
</Title>
</Head>
<Body>
Hello User!... <br> <center>
<img src="https://placehold.co/400x300/9b59b6/ffffff?text=Logo" width="100" height="100" > </center>
</Body>
</Html>