The multiple selector combines several CSS selectors with commas. jQuery returns the union of all matches — every element that matches any of the listed selectors — in one collection. Available since jQuery 1.0 (standard CSS).
Remember
$("selector1, selector2, selectorN")
$("div, span") → all divs OR all spans
$("div, span, p.myClass") → divs, spans, and p.myClass
$("div span") → descendant (space), not OR
$("div.active") → AND (chained), not OR
List selectors separated by commas, then chain any jQuery method on the combined set.
Decide which unrelated groups you need (tags, classes, IDs, attributes).
Join them with commas: $("h1, h2, .subtitle").
Apply one action to the whole set — style, events, show/hide, and so on.
Remember: results are in document order, not selector-list order.
Piece
Required?
Role
selector1 … selectorN
Yes (at least one)
Any valid CSS/jQuery selectors
Comma
Yes (for a union)
OR combinator between selectors
Spaces around commas
Optional
div,span equals div, span
Pseudocode
Pseudocode
parts = split(selectorString, by comma)
matches = empty set
for each part in parts:
matches = matches ∪ find(part)
remove duplicates from matches
sort matches by document order
return jQuery(matches)
Reference
Cheat Sheet
Keep these facts handy while writing comma selectors.
Topic
Detail
Syntax
$("sel1, sel2, selN")
Logic
OR (union), not AND
Order
Document order (DOM tree)
Duplicates
Each element appears once
vs space
div, span ≠ div span
vs .add()
Same union; .add() for dynamic sets
Since
jQuery 1.0 (standard CSS)
Try it
Live Preview
Pick a selector against a small sample DOM and see which tags match (and in what order).
Sample markup mirrors the official jQuery multiple-selector demos.
Comma path. One string selects divs and spans together.
.add() path. Start with divs, then append spans to that set.
Compare lengths. Both collections hold the same union of nodes.
When to choose. Static query → comma. Existing set or dynamic pieces → .add().
Example 4 — Comma OR vs Descendant Space
See how $("div, span") differs from $("div span") on the same markup.
jQuery
console.log("comma:", $("div, span").length);
console.log("space:", $("div span").length);
// comma → every div and every span
// space → only spans nested inside a div
Huge comma lists can match more than you intend. Scope with a parent context: $("#panel").find("h1, h2").
Compatibility
Browser Support
The multiple selector is standard CSS and has worked in jQuery since 1.0. Modern browsers implement comma-separated selectors in native querySelectorAll.
✓ CSS · jQuery 1.0+
jQuery "sel1, sel2, selN"
Supported in all modern browsers. Native: document.querySelectorAll("div, span, p.myClass"). Universal CSS comma combinator.
100%Standard CSS selector
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
Comma combinatorUniversal
Bottom line: Safe everywhere jQuery runs. Prefer comma for static unions; use .add() when extending an existing collection at runtime.
Analysis
Performance Notes
Approach
Cost
Best for
$("a, b, c")
One engine pass (union)
Static disparate groups
$("a"); $("b"); $("c")
Three separate queries
Avoid when you need one set
$("a").add("b")
Extra merge step
Dynamic / incremental unions
Official docs call the multiple expression combinator an efficient way to select disparate elements. Keep lists focused; scope under a container when the page is large.
Remember
Key Takeaways
Role: comma = OR union of several selectors in one $() call.
Order: results follow the DOM, not your selector list.
One line: use $("sel1, sel2, selN") to select disparate elements efficiently in one query.
Frequently Asked Questions
It combines several selectors with commas into one query. $("div, span, p.myClass") returns every element that matches any listed selector — all divs, all spans, and all p.myClass elements — in a single jQuery collection.
Comma is OR (union). Each selector runs on its own and results are merged. Chained tokens without a comma — like div.active — use AND logic instead.
In document order (DOM tree order), not the order you wrote the selectors. $("div, p, span") may return a span first if it appears before a div in the HTML.
$("div, span") selects all divs and all spans (OR). $("div span") selects spans nested inside a div (descendant). Comma widens; space narrows.
Use .add() when you already have a jQuery collection and want to append more matches — for example $("div").add("span"). For one static query string, prefer the comma combinator.
Since jQuery 1.0. It is standard CSS and works via native querySelectorAll in modern browsers.