Home >>jQuery Tutorial >jQuery multiple elements Selector

jQuery multiple elements Selector

jQuery multiple elements Selector

jQuery element selector in jQuery can also be used to select multiple elements, you can separate Each element with comma.

Syntax:
$("element1,element2,element3,...")

Parameter Values

Parameter Description
element It is a Required parameter and used to specifies the elements to be selected
Here is an Example of jQuery multiple elements Selector:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".head, .box, .txt").css("background-color", "lightgreen");
});
</script>
</head>
<body>
<h2 class="head">Nice to meet you</h2>
<div class="box">Very nice .</div>
<p class="txt">How are you?</p>
</body>
</html>

Output:

Nice to meet you

Very nice .

How are you?