Lessons in this course (10)
2. Selectors and filtering
Basic★ Must knowLesson 2 of 10
js
$("#orderForm") // id
$(".order-row") // class
$("table tr:even") // jQuery extension pseudo-selector (avoid for performance; use CSS where possible)
$("input[type='email']") // attribute
$("ul > li:first-child") // CSS
$("#orders").find(".paid") // descendant search — faster than one complex selector
$(".item").filter(".active") // narrow a set
$(".item").not(".disabled")
$(".item").eq(2) // third element
$(".item").first() / .last()
$("li").has("ul") // contains matching descendants
$("#el").is(":visible") // test → boolean
const $rows = $(".order-row"); // cache selections (prefix $ by convention)
const raw = $rows[0]; // or $rows.get(0) → plain DOM element
$(raw) // wrap a DOM element