Example 1 — Official Demo: #prev ~ div
Select every div sibling that follows #prev (jQuery API example).
var tags = $("#prev ~ div").map(function () {
return this.tagName;
}).get().join(", ");
console.log($("#prev ~ div").length);
console.log(tags); How It Works
- Anchor on
#prev. Matching starts after that element. - Keep following divs. Each sibling
divafter#previs kept. - Skip non-divs. A following
spandoes not match the filter.

