jQuery multiple classes Selector (original) (raw)
Last Updated : 11 Jul, 2025
The jQuery multiple class selector is used to select multiple classes of an HTML document.
Syntax:
$(".class1, .class2, .class3, ...")
Parameter:
- class: This parameter is required to specify the class of the elements to be selected.
Example 1: In this example, we will select the multiple classes by using jQuery multiple class selector.
HTML `
<script>
$(document).ready(function () {
$(".geeks, .for, .GeeksforGeeks").css(
"background-color", "green");
});
</script>
Welcome to GeeksforGeeks
Geeks1
Geeks2
Geeks3
Geeks3
`
Output:
Example 2: In this example, we will change the background color of the classes we have selected.
HTML `
<script>
$(document).ready(function () {
$(".c1, .c2").css(
"background-color", "green");
});
</script>
Welcome to GeeksforGeeks
Geeks1
Geeks2
Geeks3
Geeks3
`
Output: