jQuery – Has Attribute Selector [name]

This jQuery selector selects elements that have the specified attribute, with any value.

Source Code

<!DOCTYPE html>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
<h4 id="number1" number="even">Number - 6</h6>
<h4 id="number2" number="odd">Number - 5</h6>
<button>Click Here</button>

jQuery(&quot;button&quot;).click(function () {


Following example fetch the ‘number’ attribute and display it as an alert message.

Number – 6

Number – 5


No comments yet.

Leave a Reply