Skip to content
Justice Tech School

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

How to test if an element exists?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.