agyanadda@gmail.com

jQuery Get Started

jQuery Basics 1 min read Updated Dec 1, 2026 Topic 2 of 25

Add jQuery

CDN (easiest):

<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>

Download: save jquery-3.7.1.min.js in your project (for example public/js/) and link it. Use the .min (minified) file on live sites.

Place the jQuery script before your own scripts — your code needs $ to exist.

Document ready

Run code only after the HTML is loaded:

$(function () {
  // your code here
});

This is the short form of $(document).ready(function () { ... });.

$ and jQuery

$ is just a short name for jQuery. If another library also uses $, write jQuery('.box') instead.

Example

Example — jQuery starter page HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>jQuery Starter</title>
  <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
</head>
<body>
  <h1>jQuery is ready?</h1>
  <p id="status">Checking...</p>

  <script>
    $(function () {
      $('#status').text('Yes! jQuery version ' + $.fn.jquery + ' is loaded.');
    });
  </script>
</body>
</html>

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which is the short form of the document ready event?

Exercise 2 True / False

Your own script that uses $ must be loaded before the jQuery file.

Exercise 3 Fill in the Blank

$ is a short name for ___.

Frequently Asked Questions

jQuery was not loaded (wrong path or no internet for the CDN), or your script runs before the jQuery script tag. Check the console and the script order.