Example 1 — All Ancestors of Item “A”
Official idea: from li.item-a, mark every ancestor up the tree.
$("li.item-a").parents().append(" [ancestor]"); How It Works
- Start. Select
li.item-a. - Climb. Walk from the immediate parent to the root.
- Collect. Every ancestor is in the result set.

