Using jQuery

jQuery is an extremely powerful JavaScript library. Here are a few sample pieces of code to give you a head start on your next project.

If you have downloaded the jQuery library to your hard disk and plan to use it from there, then you can include the following code in your HTML <head> tag:

<script src="js/jquery.min.js"></script> 

Here, js is a folder in the root directory of your project.

Tip

To avoid longer loading time and performance issues, scripts should be added to the end of the <body> tag because when the browser loads the web page (let's say, sample1.html) and the scripts are at the end of the body tag, the browser can render the content of the page (the body) and only start loading scripts afterward.

Another preferred approach ...

Get Web Developer's Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.