For many years, dropdown menus, tabs, form checks, animations and updating data without reloading the page were built with jQuery. Even though modern JavaScript has taken over much of what it did, it still runs on a huge number of existing websites, including many WordPress and e-commerce sites, so understanding it remains useful.

In this guide we explain what jQuery is and whether it is a programming language, how it works with the DOM, what you can do with it (selecting, changing, adding and removing elements, CSS and visibility), selectors, events, animations, AJAX, how to add jQuery to a page, where to write code, document ready, jQuery vs. plain JavaScript, how it differs from React, Vue, Angular, Bootstrap and Node.js, where it is used, plugins, noConflict, and its advantages and disadvantages.

What Is jQuery?

A free, open-source JavaScript library that makes common JavaScript tasks shorter and easier to write.

What Is jQuery For?

What Is jQuery For?

Selecting HTML elements, changing content, handling events, creating animations and sending AJAX requests.

Is jQuery a Programming Language?

No. It is a library that runs on top of JavaScript.

How Does jQuery Work?

It finds HTML elements with CSS-like selectors and applies JavaScript actions to them.

What Is the DOM?

The Document Object Model: the browser’s tree representation of the page, which scripts can read and change.

What Can You Do with jQuery?

  • Select HTML elements.
  • Change content.
  • Add HTML elements.
  • Remove HTML elements.
  • Change CSS properties.
  • Show and hide elements.

Example:

$('.menu').hide();
$('#title').text('Hello');

jQuery Selectors

They pick elements by tag, class, ID, attribute or position, using the same syntax as CSS.

jQuery Events

  • Click event
  • Hover event
  • Form submit event
$('#button').on('click', function () {
  alert('Clicked');
});

What Is the jQuery on() Method?

The standard way to attach event handlers, including to elements added later through delegation.

How to Make Animations with jQuery

  • Fade effects: fadeIn(), fadeOut().
  • Slide effects: slideUp(), slideDown().
  • Custom animation: animate().

What Is jQuery AJAX?

A way to exchange data with a server without reloading the page.

$.ajax({ url: '/api/items', method: 'GET' }).done(function (data) { /* use data */ });

Shortcuts include $.get() and $.post().

AJAX vs. a Normal Page Request

A normal request reloads the whole page. AJAX updates only part of it.

How to Add jQuery

  • With a local file: download it and link it with a script tag.
  • With a CDN: link a hosted copy. See what is a CDN.

Where to Write jQuery Code

In a script block in the HTML or, better, in a separate JavaScript file.

What Is Document Ready?

Code wrapped in $(document).ready(...) runs after the page structure is loaded.

jQuery vs. JavaScript

TaskjQueryPlain JavaScript
Select an element$('.box')document.querySelector('.box')
Click event$('.box').on('click', fn)el.addEventListener('click', fn)
Add a class$('.box').addClass('on')el.classList.add('on')
Change content$('.box').text('Hi')el.textContent = 'Hi'

jQuery vs. React, Vue and Angular

Those are frameworks for building whole applications with components and state. jQuery directly manipulates the page. See commonly used software architectures and Flutter.

jQuery vs. Bootstrap

Bootstrap is a CSS and component framework for layout and styling; older versions used jQuery for some components. See what is a grid system.

jQuery vs. Node.js

Node.js runs JavaScript on the server. jQuery runs in the browser.

Where Is jQuery Used?

  • WordPress sites. See what is WordPress.
  • E-commerce sites.
  • Corporate websites.
  • Admin panels.
  • Existing and legacy projects.

What Is a jQuery Plugin?

An add-on that provides ready features such as sliders, galleries and date pickers.

What Is jQuery noConflict?

A mode that releases the $ symbol so jQuery can coexist with other libraries that use it.

Advantages of jQuery

  • Less code.
  • Relatively easy to learn.
  • Smoother browser compatibility.
  • A large plugin ecosystem.
  • Easier AJAX.
  • Widespread in existing projects.
  • Fast prototyping.

Disadvantages of jQuery

Should You Still Learn jQuery?

If you work on existing sites, yes. For new projects, learn modern JavaScript and a framework first.

See also what does a web designer do, how to prepare professional web design and our web design service.

Frequently Asked Questions

What is jQuery?

An open-source JavaScript library that makes writing JavaScript operations shorter and easier.

What is jQuery for?

Selecting HTML elements, changing content, handling events, creating animations and sending AJAX requests.

Is jQuery a programming language?

No. It is a library that runs on JavaScript.

What does jQuery stand for?

It isn’t an abbreviation. It is a library name that reflects its approach of querying and selecting in JavaScript.

Is jQuery free?

Yes. It is open source and can be used free of charge under its license terms.

How does jQuery work?

It finds HTML elements using CSS-like selectors and applies JavaScript actions to them.

What can be done with jQuery?

Menus, forms, animations, sliders, galleries, AJAX, filtering and dynamic content operations.

How is jQuery added?

By downloading the file or through a CDN link, using a script tag in the HTML page.

Where is jQuery code written?

In a script area in the HTML or in a separate JavaScript file.