.siblings() gets the siblings of each element in the current set — all elements that share the same parent, excluding the element itself. Optional selector filter. Available since jQuery 1.0.
Remember
$("li.third-item").siblings() → 1, 2, 4, 5 (not 3)
$("p").siblings(".selected") → filtered siblings only
Parent
├─ item 1 ← sibling
├─ item 2 ← sibling
├─ item 3 ← start (excluded)
├─ item 4 ← sibling
└─ item 5 ← sibling
.next() / .prev() → one neighbor
.nextAll() / .prevAll() → one direction
.siblings() → both directions, minus self
Start from one (or more) elements, then collect peers under the same parent.
Select the starting element(s): $("li.third-item").
Call .siblings() for all peers, or .siblings("sel") to filter.
Remember: the start element is never included.
For multi-start exclusive peers, use .siblings().not($collection).
Piece
Required?
Role
Starting set
Yes
Elements whose peers are collected
Selector
Optional
Keeps only matching siblings
Self
—
Always excluded from the result
Pseudocode
Pseudocode
starts = current jQuery set
result = empty
for each el in starts:
for each sibling of el (same parent, not el):
if no selector or sibling matches selector:
keep sibling
return jQuery(result) // unique nodes; starts not included as "self"
Reference
Cheat Sheet
Keep these facts handy while collecting siblings.
Topic
Detail
Syntax
.siblings( [selector] )
Direction
Both sides (before and after)
Includes self?
No
vs .next() / .prev()
All peers vs one neighbor
vs .nextAll() / .prevAll()
Both directions vs one
Exclusive peers
.siblings().not($collection)
Since
jQuery 1.0
Try it
Live Preview
Start at li.third-item and compare sibling methods on a five-item list.
Official pattern: from item 3, .siblings() returns items 1, 2, 4, and 5 — not 3.
list item 1
list item 2
list item 3
list item 4
list item 5
Result
$("li.third-item").siblings()
matched: 4
text: list item 1, list item 2, list item 4, list item 5
/* self (item 3) excluded */
Code
jQuery Examples
Short, copy-ready snippets. Open a browser console with jQuery loaded, or use Try It Yourself for a live editor.
Example 1 — Official: $("li.third-item").siblings()
Get every sibling of the third list item (jQuery API example).
starts: 2
plain siblings: One, Two, Three, Four
exclusive: Two, Three
How It Works
Two starts. One and Four both have class hilite.
Plain .siblings(). Unique merge includes One and Four (each is a sibling of the other).
.not($hilite). Drops the original starts → Two and Three only.
Exclusive peers. Official tip for multi-element starts.
Edge Cases & Pitfalls
Check these before relying on .siblings() in real projects.
self
Start element excluded
The matched element is never returned as its own sibling — easy to forget when counting “everyone at this level.”
multi
Mutual siblings in the start set
Official docs: if the collection has multiple mutual siblings, they can appear in each other’s results. Use .not($collection) for exclusive peers.
text
Element siblings only
.siblings() returns element nodes, not text nodes between tags.
scope
Same parent only
Cousins under a different parent are not siblings. Scope starts carefully in nested lists.
Compatibility
Browser Support
.siblings() is a core jQuery traversing method available since 1.0. It works wherever jQuery runs.
✓ jQuery 1.0+ · Core API
jQuery .siblings()
Works in all browsers with jQuery. Optional selector filters the peer set.
100%jQuery environments
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.siblings()Core method
Bottom line: Safe to use for same-parent peers; remember self is excluded and multi-starts may need .not($collection).
Analysis
Performance Notes
Approach
Cost
Best for
$("#id").siblings()
Small peer list
Typical UI work
$("li").siblings()
Many starts × peers
Avoid on huge lists
.siblings("sel")
Peers + filter
When you only need some peers
Prefer a single, specific start when you can. Wide starts that are mutual siblings also inflate the result — filter early with a selector or .not().
Remember
Key Takeaways
Role: get all same-parent peers, excluding self.
Both sides: unlike .nextAll() / .prevAll() alone.
Filter: pass a selector to keep matching siblings only.
Multi-start: use .not($collection) for exclusive peers.
One line:.siblings() means “everyone else under my parent” — both directions, never myself.
Frequently Asked Questions
.siblings() returns every sibling of each element in the current set — elements that share the same parent, excluding the element itself. An optional selector filters which siblings are kept. Available since jQuery 1.0.
.next() and .prev() return at most one immediate neighbor. .siblings() returns all siblings on both sides. From list item 3, .next() is item 4 only; .siblings() is items 1, 2, 4, and 5.
.nextAll() is only following siblings; .prevAll() is only preceding. .siblings() combines both directions (minus self).
No. The matched element is never in the result. Official demo from item 3 styles 1, 2, 4, and 5 — not 3.
When the starting set has multiple mutual siblings, plain .siblings() can return members of the original set. Chain .not($collection) for an exclusive list of other siblings only.
Yes. Pass a selector: $("p").siblings(".selected") keeps only sibling elements that match .selected.