Example 1 — Official: $("li.third-item").siblings()
Get every sibling of the third list item (jQuery API example).
var $hits = $("li.third-item").siblings();
console.log($hits.length);
console.log($hits.map(function () {
return this.textContent.trim();
}).get().join(", ")); How It Works
- Start at item 3.
$("li.third-item")is the root. - Collect peers. Same parent
ul, both directions. - Skip self. Item 3 is not in the result.

