jQuery is a JavaScript library — a file of ready-made functions. Its motto is "write less, do more".
// Plain JavaScript
document.querySelectorAll('.box').forEach(el => el.style.display = 'none');
// jQuery
$('.box').hide();
What can jQuery do?
- Select and change HTML elements easily
- Handle events like click, submit and keyup
- Add effects: hide, show, fade, slide, animate
- Make AJAX requests to load data without reloading
- Work the same way in all browsers
Should you still learn jQuery?
Modern JavaScript can do most of what jQuery does, and new projects often use React or Vue. But jQuery is still used on millions of websites — WordPress themes, Bootstrap 4 projects, admin panels, DataTables and many Laravel/PHP apps. Knowing it helps you maintain real projects and get jobs.
This tutorial uses jQuery 3.7.1. Learn basic HTML, CSS and JavaScript first.
Example
Example — Your first jQuery code
HTML
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<h2 id="title">Hello!</h2>
<p class="msg">Click the button to hide this paragraph.</p>
<button id="btn">Hide</button>
<script>
$(function () {
$('#btn').click(function () {
$('.msg').hide();
$('#title').text('jQuery did that!');
});
});
</script>