Home >>jQuery Tutorial >jQuery [attribute=value] Selector
The [attribute=value] selector in jQuery is used to selects each element with the specified value and attribute.
Syntax:$("[attribute=value]")
Parameter | Description |
---|---|
attribute | It is a Required parameter and used to specifies the attribute to find |
value | It is a Required parameter and used to specifies the value to find |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("[id=option]").css("background-color", "#4796d6");
});
</script>
</head>
<body>
<h1>Welcome to Phptpoint</h1>
<p class="attr1">My name is phptpoint</p>
<p>I live in Noida</p>
Who is your favourite:
<ul id="option">
<li>JAVA</li>
<li>jQuery</li>
<li>Javascript</li>
</ul>
</body>
</html>
My name is phptpoint
I live in Noida
Who is your favourite: