jQuery Introduction

jQuery is a small JavaScript library. It was created by John Resig in 2006 with a simple idea: “write less, do more”. With jQuery you can select HTML elements, change them, handle clicks, make animations and talk to the server with very short code, and the code works the same in all browsers.

What can you do with jQuery?

  • Select and change HTML elements (text, attributes, styles, classes).
  • Handle events like click, hover, key press and form submit.
  • Add effects and animations like hide, show, fade and slide.
  • Send Ajax requests to get or send data without reloading the page.
  • Walk through the DOM to find parents, children and siblings.

jQuery vs plain JavaScript

Years ago, each browser had its own way for many things, and jQuery made life easy. Today the browsers are much better, and plain JavaScript can do many of the same jobs. But jQuery code is still shorter for many tasks. Here is the same example in both ways: a button click changes a message.

<button id="btn">Click me</button>
<p id="msg">Waiting...</p>

Plain JavaScript:

document.getElementById('btn').addEventListener('click', function () {
  document.getElementById('msg').textContent = 'Button clicked';
});

document.getElementById('btn').click();   // we simulate a click here
console.log(document.getElementById('msg').textContent);
Console output

Button clicked

jQuery:

$('#btn').on('click', function () {
  $('#msg').text('Button clicked');
});

$('#btn').click();   // we simulate a click here
console.log($('#msg').text());
Console output

Button clicked

Both give the same result. In these examples, the click is simulated by code, so we can see the output here. On a real page, the user clicks with the mouse.

Why do people still use jQuery?

  • WordPress and old sites: a lot of themes and plugins use jQuery, and WordPress includes it. You will meet it in real projects.
  • Short and simple code for common tasks, and a big number of plugins.
  • Works in all browsers in the same way, and is well tested.
  • Small learning curve for beginners.

jQuery versions

The 3.x line (the latest is 3.7.1) is the most used. jQuery 4.0 is the new major version, released in January 2026. It removes some old functions and drops very old browsers, but almost all the code in this tutorial works in both versions. We ran all the examples of this tutorial with jQuery 3.7.1 and with 4.0.0, so you can use them in both. Read jQuery 4 and Upgrading for the changes.

Should you learn jQuery?

If you will work with WordPress, with old projects, or you want to understand a lot of existing code, yes. For a brand new big application, many teams now use plain JavaScript or a framework. You can read about it in jQuery vs Vanilla JavaScript. It helps to know some JavaScript and HTML before you start.

What you will learn in this tutorial

  • Install jQuery, syntax and the document ready event.
  • Selectors, events and effects.
  • Get and set content, attributes, classes and CSS.
  • Add and remove elements, and walk through the DOM.
  • Ajax, forms, plugins and the differences with jQuery 4.
Note: Type the examples yourself and change them. Next: jQuery Get Started.

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
What is jQuery?
What are the advantages of jQuery?
What is the difference between jQuery and JavaScript?
How do you add jQuery to a web page?
What is the document ready function in jQuery?
What is the difference between $(document).ready() and window.onload?
What is the $ sign in jQuery?