Home >>jQuery Tutorial >jQuery multiple classes Selector
jQuery .class selector in jQuery is used also can be used to select multiple classes and Separate each class with a comma.
Syntax:$(".class1,.class2,.class3,...")
Parameter | Description |
---|---|
class | It is a required parameter and used to specifies the class of the elements to select |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".box, .box1, .box2").css("background-color", "lightgreen");
});
</script>
</head>
<body>
<p class="box">This is First paragraph.</p>
<p>This is Second paragraph.</p>
<p class="box1">This is Third paragraph.</p>
<p>This is Fourth paragraph.</p>
<p class="box2">This is Fifth paragraph.</p>
</body>
</html>
This is First paragraph.
This is Second paragraph.
This is Third paragraph.
This is Fourth paragraph.
This is Fifth paragraph.