jQuery remove attribute method function


To remove the attribute of HTML element we will use the jquery removeAttr() function. Below is the example that how we can remove the attribute of HTML element.

$("TagSelector").removeAttr("attributeName");

Remove the Placeholder of input field with name='username'

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <button> Remove Place Holder </button> <input name='username' placeholder="Enter Username. . . ." /> <script type="text/javascript"> $("button").click(function() { $("input[name='username']").removeAttr('placeholder'); }); </script>

Output

Chapter Next »