jQuery Introduction

Beginner
6 min read
Updated: Oct 2026
JavaScript library

What Is jQuery?

jQuery is a fast, lightweight JavaScript library that simplifies DOM selection, events, animations, and AJAX. It wraps browser APIs in a concise $() syntax so common front-end tasks take fewer lines.

Remember
Core pattern:
  $(selector).action()

Ready handler (run after HTML parses):
  $(function () { ... })

Same idea: $(document).ready(function () { ... })

These tutorials use jQuery 3.7.1. jQuery still powers many legacy sites, WordPress themes, and dashboards even as newer apps prefer vanilla JS or frameworks.

Why Use jQuery?

Plain JavaScript can do everything jQuery does—jQuery just makes everyday DOM work shorter and more consistent across browsers.

NeedHow jQuery helps
Select elementsCSS-style selectors via $()
Handle clicks & forms.on() with easy event delegation
Animate UIBuilt-in .fadeIn(), .slideToggle(), and more
Fetch dataSimple AJAX helpers like $.get and $.ajax

How jQuery Runs

Your page loads jQuery, then your script talks to the DOM through $:

StepWhat happens
1. LoadBrowser loads jQuery from CDN or a local file
2. Ready$(function(){…}) waits until the HTML is parsed
3. Select$("#id"), $(".class"), or any CSS selector
4. ActChain methods: .text(), .on(), .fadeIn()

Your First jQuery Script

Include the CDN, then update a paragraph when the DOM is ready:

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>jQuery CDN setup</title>
</head>
<body>
  <h1>jQuery CDN demo</h1>
  <p id="status">Loading jQuery...</p>

  <!-- Place before your own scripts -->
  <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
  <script>
    $(function () {
      $("#status").text("jQuery " + $.fn.jquery + " is ready.");
    });
  </script>
</body>
</html>
Try It Yourself

How It Works

1. Load. The CDN script defines $ / jQuery on the page.

2. Ready. $(function () { ... }) runs after the HTML is parsed.

3. Update. $("#status").text(...) selects the paragraph and sets its text.

Next, explore callback objects in jQuery Callbacks.

jQuery vs Vanilla vs Frameworks

Pick the tool that matches the project:

OptionStyleChoose when…
jQueryLibrary helpers on the DOMLegacy sites, quick enhancements, WordPress
Vanilla JSBuilt-in browser APIsNo dependency; modern browsers only
React / VueComponent frameworksLarge SPAs with complex UI state

Same job, two styles

Hide an element with id banner:

JavaScript
$("#banner").hide();
JavaScript
document.getElementById("banner").style.display = "none";

When to use which

Use jQuery when…Prefer vanilla / frameworks when…
You maintain an existing jQuery codebaseYou start a greenfield modern app
You need short DOM/event helpers quicklyYou want zero library weight
Plugins or WordPress already expect itYou need a component-driven SPA

Core Building Blocks

These pieces show up in almost every jQuery script:

ConceptWhat it doesExample
$()Select elements or wrap the ready handler$("#msg")
ChainingCall several methods on the same set$("#x").hide().fadeIn()
EventsListen for user actions.on("click", fn)
DOMRead or change content and attributes.text(), .html(), .attr()
EffectsShow, hide, and animate.fadeOut(), .slideUp()
AJAXTalk to a server without reloading$.get(url)

Where Is jQuery Used?

jQuery still appears across a lot of the live web:

Use caseWhy jQuery fits
Legacy websitesAlready wired; cheaper to extend than rewrite
WordPress themes & pluginsMany still ship jQuery by default
Admin dashboardsQuick toggles, tables, and form helpers
Light interactivityMenus, modals, and tabs without a full SPA
AJAX formsSubmit and update page sections without reload
PrototypesFast DOM demos with little setup

Key Takeaways

  • jQuery is a JavaScript library—not a separate language.
  • Pattern: $(selector).action() after DOM ready.
  • Load order: jQuery script first, then your code.
  • Today: great for legacy; learn JS fundamentals either way.

One line: jQuery shortens DOM work with $()—next, learn callbacks.

Frequently Asked Questions

jQuery is a fast, lightweight JavaScript library that simplifies DOM selection, event handling, animations, and AJAX. It wraps browser APIs in a concise $() syntax so you write less code for common front-end tasks.
Yes. jQuery is built on JavaScript—you should understand variables, functions, and basic DOM concepts first. jQuery saves boilerplate; it does not replace learning how JavaScript works.
Yes, especially in legacy websites, WordPress themes, and admin dashboards. Modern greenfield apps often use React, Vue, or vanilla JavaScript, but millions of pages still rely on jQuery and it remains valuable to maintain and extend those projects.
Add a script tag pointing to the jQuery CDN or a local copy before your own scripts. Then wrap your code in $(function() { ... }) so it runs after the HTML is parsed.
JavaScript is the programming language. jQuery is a library written in JavaScript that provides helper methods. Anything you do with jQuery can be done with plain JavaScript—it just usually takes more lines and cross-browser handling.
Practice selectors, .on() for events, .html()/.text() for content changes, and simple animations. Then explore AJAX, callbacks, deferred objects, and plugin usage on real pages.

Did you know?

Include jQuery with a <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> tag, wait for the DOM with $(function() { ... }), select elements with $(), and chain methods like .hide(), .on('click'), and .fadeIn().

Next: jQuery Callbacks

See how jQuery manages lists of callback functions.

Callbacks →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful