Home >>jQuery Tutorial >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 | 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").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>
My name is jQuery
I live in Noida
I live in Noida