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 is to use the Google hosted libraries; these provide faster rendering to your pages and jQuery code than using your own hosted jQuery libraries. You can use the Google developer hosted libraries with the following piece of...