Skip to content
BENIBIX Learn

jQuery

Development🌐 Web DevelopmentFrameworks

Also known as jQuery Library, $(), jQuery JS

A JavaScript tool that makes it quick to find and change parts of a web page.

Think of it like

It is like a remote control for the page. One short press does a long job.

Example

Lucy takes over an old shop site. Its code is full of $(...) calls, so she learns enough jQuery to fix the menu.

Why it matters

You will meet it in a huge number of older sites. Knowing it helps you read and fix them.

Definition

jQuery is a free JavaScript library that makes it short to find and change parts of a web page. You find elements with $ and a CSS selector, like $(".btn"). Then one short call can hide them, change them or react to clicks. It also smooths over the ways old browsers differ. Newer browsers now do most of this on their own, but many sites still use it.

Example code

javascript
$(".btn").on("click", function () {
  $("#menu").toggle();
});
Now each thing with the class btn opens and shuts the menu when you click it.
jQuery, on the left, finds parts of the page and changes them in one line.

Common mistake

Adding it to a new project just to find parts of the page. Plain JavaScript now does that with querySelector.

Key takeaways

  1. 1
    Find with $. Pass a CSS selector to $().
  2. 2
    Short calls. One line hides, shows or changes.
  3. 3
    Common in old sites. New sites rarely need it.

Compare