$("[attribute_name]")
Parameter:
- attribute_name: It is the required parameter which specify the attribute to be select.
<html>
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
script>
<script>
$(document).ready(function() {
$("[class]").css("color",
"green");
});
script>
head>
<body>
<center>
<h3 class>GeeksforGeeksh3>
<p>A computer science portal for geeksp>
<p id>Geek1p>
<p class>Geek2p>
<p>Geek3p>
<div class> Thank You! div>
center>
body>
html>
In the above example, all the elements with the specified attribute (class) are formatted into green color i.e, "GeeksforGeeks", "Geek2" and "Thank You!".
Example-2:
<html>
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
script>
<script>
$(document).ready(function() {
$("[class]").css("color",
"green");
});
script>
head>
<body>
<center>
<h3 class="demo">GeeksforGeeksh3>
<p>A computer science portal for geeksp>
<p id>Geek1p>
<p>Geek2p>
<p class="test">Geek3p>
<div class="sample"> Thank You! div>
center>
body>
html>
In the above example, all the elements with the specified attribute (class) are formatted into green color rather considering the value of the attribute. "GeeksforGeeks", "Geek3" and "Thank You!" are formatted.