Example 1 — Official Demo: ul li:nth-child(2)
Mark the second list item in every ul (jQuery API example).
$("ul li:nth-child(2)").each(function () {
this.textContent = this.textContent + " - 2nd!";
});
console.log($("ul li:nth-child(2)").length); How It Works
- Scan each list. Every
ulhas its own child positions. - Require index 2. Only the second child is a candidate.
- Require an
li. The second child must also be a list item.

