Example 1 — Mark All Previous List Items
Official idea: from item 3, select every preceding sibling.
$("li.third-item").prevAll().prepend("[prev] ");
// items 1 and 2 both get the marker How It Works
- Start. Select
li.third-item. - Collect.
.prevAll()finds items 2 and 1. - Mark.
.prepend("[prev] ")labels each match.

