Home >>jQuery Tutorial >jQuery .class Selector

jQuery .class Selector

jQuery .class Selector

jQuery .class selector in jQuery is used to selects all elements with the specific class attribute of an HTML element.

Syntax:
$(".class")

Parameter Values

Parameter Description
class It is a required parameter and used to specifies the class of the elements to select
Here is an Example of jQuery .class Selector:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".box").css("background-color","pink");
});
</script>
</head>
<body>
<p class="box">My name is jQuery</p>
<p>I live in Noida</p>
<div class="box">My name is Java</div>
<p>I live in Noida</p>
</body>
</html>

Output:

My name is jQuery

I live in Noida

My name is Java

I live in Noida


No Sidebar ads