Combine and group CSS selectors
mainYou can refine or expand your selections using these patterns:
- Combining (AND logic): Write selectors next to each other to require an element to match all of them (e.g.,
$('p.selected')matches<p>elements that also have the classselected). - Grouping (OR logic): Separate selectors with a comma to match any of them (e.g.,
$('h1, h2')matches all<h1>and<h2>elements).
// <p> elements that also have the class `selected`
const $selected = $('p.selected');
// All <h1> and <h2> elements
const $headings = $('h1, h2');