Home >>jQuery Tutorial >jQuery attribute Selector

jQuery attribute Selector

jQuery [attribute] Selector

jQuery [attribute] selector in jQuery is used to selects each element with the specified attribute.

Syntax:
$("[attribute]")

Parameter Values

Parameter Description
attribute It is a Required parameter used to specifies the attribute to find
Here is an Example of jQuery [attribute] Selector:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("[id]").css("background-color", "#4796d6");
});
</script>
</head>
<body>
<h1>Welcome to Phptpoint</h1>
<p class="attr">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>

Output:

Welcome to Phptpoint

My name is phptpoint

I live in Noida

Who is your favourite:
  • JAVA
  • jQuery
  • Javascript

No Sidebar ads