Example 1 — Count Every Element in the Document
Official idea: $("*") matches the whole document. Read .length to see how many elements exist.
var elementCount = $("*").length;
console.log(elementCount + " elements found"); How It Works
- Run the universal selector.
$("*")collects every element from the document root. - Read the count.
.lengthreturns how many nodes matched — no loop needed. - Expect a large number. Real pages include head tags, scripts, and chrome.

