jQuery Tutorial

jQuery Tutorial for beginners to learn jQuery online for free.

jQuery is a lightweight JavaScript library used to simplify the JavaScript functions such as animation, validation and DOM manipulation.

This Tutorial covers basics, selectors, DOM manipulation, traversing, event handling, animation, and Ajax. There are many jQuery third-party plugins that can be used into the website. We cover popular jQuery gallery, slider, and lightbox integration step by step.

In this online jQuery training course, you will get an understanding of jQuery usage with easy examples. You will also find useful exercise, codes, Interview Questions to enhance your knowledge at the end of the most chapters.

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…

jQuery Get Started

To use jQuery you only need to add one script file to your page. There are two common ways. 1. Use a CDN (the easy way) A CDN (Content Delivery Network) is…

jQuery Syntax

The basic syntax of jQuery is very simple. You select some HTML elements, and then you do an action on them. The dollar sign $ says that we use jQuery. It is…

jQuery Document Ready Function

The browser reads a page from top to bottom. If your script runs before the HTML elements are created, jQuery cannot find them. The document ready function makes your code wait until…

jQuery Selectors

Selectors are the most important part of jQuery. They find the HTML elements which you want to work with. They are based on CSS selectors, and jQuery adds some more. The page…

jQuery Events

An event is something that happens on the page: a click, a key press, a form submit, a mouse move. With jQuery you can run your own function when an event happens….

jQuery Mouse, Keyboard and Form Events

In this chapter we see the events which you will use most: mouse, keyboard and form events. Each example is run, and the output is real. Mouse events mouseenter and mouseleave work…

jQuery Event Delegation

A normal event handler works only for the elements which exist when you attach it. If you add new elements later (with append, or from Ajax), they do not get the handler….

jQuery Effects: hide, show and toggle

jQuery can show and hide elements with simple methods. You can do it at once or with an animation. hide() and show() hide() sets display: none, and show() puts back the normal…

jQuery Fade and Slide Effects

Fade and slide are the most used jQuery effects. Fade changes the opacity of an element. Slide changes the height, like a window blind, and it is very good for menus and…

jQuery animate() Method

The animate() method changes the CSS properties of an element step by step, to make your own animation. The other effects, like fadeIn and slideUp, are made with it. Syntax properties: an…

jQuery Method Chaining and Callbacks

Most jQuery methods return the jQuery object they were called on. This lets you add the next method right after, in a long “chain”. You find the elements only one time, so…

jQuery Get Content and Attributes

jQuery has simple methods to read the content, the form values and the attributes of elements. The page for the examples text(), html() and val() Method Returns .text() The text of the…

jQuery Set Content and Attributes

The same methods that read content can also change it. You only pass a value as the argument. Set text, html and value .text() treats the value as plain text, so special…

jQuery Add Elements: append, prepend, after, before

jQuery can create and insert new HTML elements in the page. There are four main methods, depending on the position. Method Adds the content append() At the end, inside the selected element…

jQuery Remove Elements: remove, empty, detach

To delete elements from the page, jQuery has a few methods. They look similar, but they do different things. Method What it does .remove() Removes the element and everything inside it, with…

jQuery CSS Classes: addClass, removeClass, toggleClass

The best way to change the style of an element is to change its CSS class. You write the style in your CSS file, and jQuery only switches the class. The code…

jQuery CSS Methods

The .css() method reads and changes the style of an element. It is the quick way when the value comes from your code. Get a CSS property Notice that the color is…

jQuery Dimensions and Position

jQuery has methods to read and set the size and the position of elements, and the scroll position of the page. All of them return numbers without the “px” unit. Note: these…

jQuery Traversing: Ancestors

Traversing means “moving through” the DOM. From one element you can find its parents, children and siblings. In this chapter we go up the tree to find the ancestors. Method Returns .parent()…

jQuery Traversing: Descendants

To go down the tree and get the elements inside another element, jQuery has two main methods: children() and find(). Method Returns .children() Only the direct children (one level down) .find(sel) All…

jQuery Traversing: Siblings

Siblings are elements with the same parent. jQuery has methods to move sideways between them. Method Returns .siblings() All siblings, except the element itself .next() The next sibling .nextAll() All next siblings…

jQuery Traversing: Filtering

Sometimes a selector finds more elements than you need. The filtering methods help to narrow the selection. Method Meaning .first() / .last() The first or the last element .eq(n) The element at…

jQuery each() and map()

When you need to do something different for each element of a selection, or loop over an array or an object, use each(). For many tasks you do not need a loop,…

jQuery load() Method

Ajax lets a page get data from the server without a reload. The easiest Ajax method of jQuery is load(): it gets HTML from a file and puts it inside the selected…

jQuery Ajax: ajax(), get(), post() and getJSON()

Ajax means getting or sending data to the server in the background, without reloading the page. jQuery makes Ajax easy and the same in all browsers. In this chapter the examples run…

jQuery Forms

Forms are a big part of a website. jQuery helps to read the fields, check them before sending, and submit the data with Ajax. Read field values For radio buttons, select the…

jQuery Utility Methods

The jQuery utility methods are functions which start with $. and do not work on selected elements. They help with objects, arrays and strings. $.extend(): merge objects $.extend() copies the properties of…

jQuery noConflict() Method

The dollar sign $ is just a short name for the jQuery function. But other libraries (like Prototype or MooTools in old projects) also used $ for their own function. If both…

jQuery Plugins

A jQuery plugin is a new method which you add to jQuery, so you can use it on any selection, like the built in methods. There are thousands of ready plugins (sliders,…

jQuery Deferred, Promises and $.when()

Some tasks take time: Ajax requests, animations, timers. A promise is an object which represents the result of such a task, which will come later. jQuery has used promises for many years,…

jQuery vs Vanilla JavaScript

“Vanilla JavaScript” means plain JavaScript without a library. Modern browsers support many features which jQuery was made for: querySelector, classList, fetch, addEventListener and more. So you can do many things without jQuery….

jQuery 4 and Upgrading from jQuery 3

jQuery 4.0.0 was released in January 2026. It is the first major version after about ten years. Most code which works in jQuery 3.x also works in 4.0, but some old methods…

jQuery Best Practices and Performance Tips

Good jQuery code is easy to read and fast. These simple habits help in both. 1. Cache your selections Every time you write $(‘#box’), jQuery searches the page. If you use the…

jQuery Cheat Sheet

This is a quick list of the most used jQuery methods. Keep it near you while you code. The links go to the chapters with the full explanation and examples. Selectors and…