Multiple ('selector1, selector2, selectorn')
JQ Home <<
Selectors <<
Multiple ('selector1, selector2, selectorn')
Multiple selector.
Shorthand version $('selector1, selector2, selectorn')
Description
The ('selector1, selector2, selectorn')
selector, selects all elements that match any of the specified selectors.
- The DOM elements selected will be returned in the jQuery object in document order and thus may not be identical.
Syntax
Signature | Description |
---|---|
jQuery('selector1, selector2, selectorn') | Multiple match |
Parameters
Parameter | Description |
---|---|
selector1 | A valid selector. |
selector2 | Another valid selector. |
selectorn | As many more valid selectors as required. |
Return
N/A.
Multiple ('selector1, selector2, selectorn')
Example
Selectors << Top
Selects all elements that match any of the specified selectors.
The following example will select all 'p' and 'i' nodes and turn the background colour yellow.
$(function(){
$('#btn1').on('click', function() {
$('p, i').css('backgroundColor', 'yellow');
});
});
The following example will select all 'div', 'h4' and 'span' nodes and turn the background colour orange.
$(function(){
$('#btn2').on('click', function() {
$('h4, span').css('backgroundColor', 'orange');
});
});
The following example will select all 'h2', 'h3' and 'b' nodes and turn the text colour maroon.
$(function(){
$('#btn3').on('click', function() {
$('h2, h3, b').css('color', 'maroon');
});
});
Related Tutorials
jQuery Basic Tutorials - Lesson 3 - CSS Selectors