Aral Code

Getting Started Lesson 1 of 10

Introduction to jQuery

What jQuery is, how the $ function works, how jQuery compares with plain JavaScript, and your first jQuery code.

jQuery was released in 2006 by John Resig. At the time, every browser behaved differently, and simple tasks needed long, browser-specific code. jQuery hid those differences behind short, friendly commands, and it quickly became the most-used JavaScript library on the web.

Your first jQuery

Example Click to hide
<script src="/vendor/jquery.min.js"></script>
<p id="note">📢 Bring your PE uniform tomorrow!</p>
<button id="hide">Got it, hide this</button>
<script>
  $("#hide").on("click", function () {
    $("#note").fadeOut();
  });
</script>

Read it as a sentence: "When #hide is clicked, fade out #note."

The $ function

Almost everything in jQuery starts with $ (which is just a short name for jQuery):

$(selector).action();
  • $(...) finds elements using CSS selectors: "#note", ".card", "li".
  • .action() does something to all of them: .hide(), .text("..."), .addClass("active").

jQuery vs plain JavaScript

TaskjQueryPlain JavaScript
Select by id$("#total")document.getElementById("total")
Change text of all .price$(".price").text("₱0")document.querySelectorAll(".price").forEach(el => el.textContent = "₱0")
Click handler$("#btn").on("click", fn)document.getElementById("btn").addEventListener("click", fn)
Hide$("#box").hide()document.getElementById("box").style.display = "none"
Fade out$("#box").fadeOut()CSS transition + extra code

The biggest convenience: jQuery acts on every matched element automatically, without loops.

Chaining

Example Several actions in one line
<script src="/vendor/jquery.min.js"></script>
<h2 id="title">Welcome!</h2>
<button id="go">Style the title</button>
<script>
  $("#go").on("click", function () {
    $("#title").text("Mabuhay! 🇵🇭").css("color", "#0038A8").slideUp(300).slideDown(300);
  });
</script>

Most jQuery methods return the same selection, so you can chain them one after another.

Where you'll find jQuery

  • WordPress themes and plugins.
  • Bootstrap 3 and 4 sites (they required jQuery; Bootstrap 5 doesn't).
  • Older company, school and government systems.
  • Plugins like date pickers, sliders and DataTables.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. What is $ in jQuery?
2. What does $(".price").text("₱0") do?
3. What is chaining?
4. Does Bootstrap 5 require jQuery?

By Sir Reyel · Last updated 2026-12-04