How to remove attribute from HTML element using jQuery

$("p").removeAttr("style");

// remove style attribute from all <p> tags 

We can remove a attribute from HTML element with the help of jQuery removeAttr() function

The below example will show us how to remove attribute from HTML element using jQuery. In this example when you click the Remove button it will remove the href attribute from the link using the jQuery removeAttr() method.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Remove HTML Element Attribute using jQuery</title>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
</head>
<body>

    <a href="#">Demo Link</a>
    <button type="button" class="remove-attr">Remove</button>

</body>
<script type="text/javascript">
    $(document).ready(function() {
        $(".remove-attr").click(function(){            
            $("a").removeAttr("href");
        });
    });
</script> 
</html>