jQuery removeAttr() Method
jQuery removeAttr() method removes one or more attributes from selected elements.
The removeAttr() method uses the JavaScript removeAttribute() function.
Syntax
Here is a syntax for the removeAttr() method
$(selector).removeAttr( attributeName );
Parameter | Type | Description |
---|---|---|
attributeName | String | Optional. Specifies one or more attributes to remove, it can be a space separated list of attributes. |
Example
Here, in this example removeAttr() method call on selected elements when click on button.
<!DOCTYPE html>
<html>
<head>
<title>jQuery removeAttr() method</title>
<script src="jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").removeAttr("style title");
});
});
</script>
</head>
<body>
<div>
<p style="background-color: yellow; text-align: center;" title="First Paragraph">First paragraph start here...</p>
</div>
<button>Click here to call removeAttr() method</button>
</body>
</html>