Category: javascript
jquery introduction and selectors
Published on 30 Sep 2026
Explanation
jQuery is a JavaScript library that simplifies DOM manipulation, event handling, animations, and AJAX operations.
Code:
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
Explanation
Use the $ function to select HTML elements using CSS-style selectors.
Code:
$('#title');
$('.box');
$('p');
Explanation
An ID selector selects a single element using its id attribute.
Code:
<h1 id="title">Hello</h1>
$('#title').text('Welcome');
Explanation
A class selector can select multiple elements that share the same CSS class.
Code:
<p class="item">One</p>
<p class="item">Two</p>
$('.item').css('color', 'blue');
Explanation
jQuery also supports attribute and descendant selectors.
Code:
$('input[name="email"]');
$('.menu li');
$('button[type="submit"]');