length and index
length counts matches and index finds position.
Example
var n = $("li").length;
var i = $("li.on").index();
if ($("#x").length) { console.log("exists"); }Exercise
Count matches.
$("li").Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.