jQuery
Selectors
Select elements by id, class, attribute, and pseudo-filters.
By EZ4Code Team
selectorsbasics
Code
// Basic selectors
$("#header"); // by id
$(".active"); // by class
$("div"); // by tag
$("*"); // all elements
// Combinators & attributes
$("ul li:first-child"); // first list item
$("a[href^='https']"); // links starting with https
$("input[type='checkbox']:checked");
// Form & content filters
$(":button"); // all buttons
$("div:contains('Hello')");
$("tr:odd"); // odd rows (zero-indexed)Explanation
jQuery selectors mirror CSS selectors and add powerful pseudo-filters like :checked, :contains, and :odd. The factory function $() returns a matched set, which is array-like and chainable. Complex queries combine combinators, attributes, and filters for concise DOM targeting.
More jQuery Snippets
Events & Delegation
Bind handlers with on(), support delegation and namespaced removal.
DOM Manipulation
Get/set text, html, attributes, classes, and insert nodes.
AJAX Requests
Use $.ajax, $.get, $.post, and load with promises.
Effects & Animation
Show, hide, fade, slide, and animate elements.
Traversing the DOM
Navigate relatives and filter the matched set.
Utility Methods
Iterate, merge, and filter with jQuery helpers.