Home >>jQuery Tutorial >jQuery removeAttr() Method

jQuery removeAttr() Method

jQuery removeAttr() Method

jQuery removeAttr() method in jQuery is used to removes one or more attributes from the selected given elements.

Syntax:
$(selector).removeAttr(attribute)

Parameter Values

Parameter Description
attribute It is a required parameter and is used to specifies one or more attributes to remove and separate the attribute names with a space
Here is an Example of jQuery removeAttr() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
$(".txt").removeAttr("style");
});
});
</script>
</head>
<body>
<h1>This is Phptpoint</h1>
<p class="txt" style="font-size:120%;color:orange;">This is First paragraph.</p>
<p class="txt" style="font-weight:bold;color:green;">This is second paragraph.</p>
<button class="btn1">click me to remove the style</button>
</body>
</html>

Output:

This is Phptpoint

This is First paragraph.

This is second paragraph.


No Sidebar ads