jQuery - Fast, Small, Feature-Rich JavaScript Library

4.0.0 · active · verified Sun Apr 19

jQuery is a venerable, fast, and feature-rich JavaScript library primarily designed for client-side HTML DOM traversal and manipulation, event handling, animation, and Ajax. The current stable version is 4.0.0, released in January 2026, following a multi-year development cycle for major versions, with minor patches and bug fixes occurring more frequently. It differentiates itself by providing a concise, cross-browser API, simplifying common web development tasks that were historically complex due to browser inconsistencies. While newer browser APIs have reduced its necessity for some tasks, it remains a widely used tool for projects requiring broad browser compatibility or leveraging its extensive plugin ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic DOM selection, event handling, AJAX (if full jQuery), CSS manipulation, animation, and dynamic content creation, showcasing jQuery's core features.

import { $ } from 'jquery';

$(function() {
  // Basic DOM manipulation
  $('#myButton').on('click', function() {
    $(this).text('Clicked!');
    $('#message').text('Button was clicked at ' + new Date().toLocaleTimeString()).css('color', 'green');
  });

  // Simple AJAX call (requires full jQuery build)
  // Check for full version presence ($.ajax will be undefined in slim build)
  if ($.ajax) {
    $('#loadData').on('click', function() {
      $('#dataContainer').html('<p>Loading data...</p>');
      $.ajax({
        url: 'https://jsonplaceholder.typicode.com/todos/1', // Example API
        method: 'GET',
        dataType: 'json',
        success: function(data) {
          $('#dataContainer').html(`
            <p>User ID: ${data.userId}</p>
            <p>Title: ${data.title}</p>
            <p>Completed: ${data.completed}</p>
          `);
        },
        error: function(jqXHR, textStatus, errorThrown) {
          $('#dataContainer').html(`<p style="color: red;">Error loading data: ${textStatus} - ${errorThrown}</p>`);
        }
      });
    });
  } else {
     $('#loadData').prop('disabled', true).text('AJAX not available (slim build)');
     $('#dataContainer').text('AJAX functionality requires the full jQuery build.');
  }

  // Chainable operations
  $('.item')
    .addClass('highlight')
    .delay(1000)
    .animate({ opacity: 0.5 }, 500)
    .css('background-color', 'yellow');

  // Add dynamic elements
  $('body').append('<div id="dynamicContent" style="padding: 10px; border: 1px solid blue; margin-top: 20px;">This is dynamically added content.</div>');
});

view raw JSON →