jQuery .removeAttr(): Delete HTML Attributes
.removeAttr() deletes named HTML attributes from every matched element. Deletion differs from setting an empty string, and multiple names can be separated by spaces.
Syntax and behavior
$("#name").removeAttr("placeholder");
$("#name").removeAttr("placeholder title");
Pass attribute names as a string without a leading dot or hash. The method returns the original jQuery object. Removing an absent attribute is harmless. Removing placeholder clears its hint, but does not clear the input’s current value.
The official jQuery .removeAttr() documentation describes additional call signatures and argument types.
Complete runnable example
Save the following code as a UTF-8 example.html file and open it in a browser. It loads the full jQuery 4.0.0 build from an external URL, so an internet connection is required. The $(function () { ... }) callback waits for the document to be ready before running the example.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery removeAttr example</title>
<style>
body { margin: 24px; font-family: sans-serif; line-height: 1.6; }
.marked { background: #fff0b3; border: 2px solid #835b00; }
.active { color: #a00000; font-weight: bold; }
button, input, select { font: inherit; }
#output { white-space: pre-wrap; overflow-wrap: anywhere; }
</style>
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
</head>
<body>
<label for="name">Name</label>
<input id="name" type="text" placeholder="Example: Alex Kim" title="Name hint">
<button id="remove" type="button">Remove hint attributes</button>
<p id="output" aria-live="polite"></p>
<script>
$(function () {
$("#remove").on("click", function () {
$("#name").removeAttr("placeholder title");
$("#output").text("placeholder present: " + document.getElementById("name").hasAttribute("placeholder") +
" / Current value: " + $("#name").val());
});
});
</script>
</body>
</html>
Expected result
Type a name before clicking Remove hint attributes. Both placeholder and title disappear, and the output shows placeholder present: false, while the typed name remains. Reloading restores the original attributes.
Empty value versus deleted attribute
$("#name").attr("placeholder", "");
console.log(document.getElementById("name").hasAttribute("placeholder")); // true
$("#name").removeAttr("placeholder");
console.log(document.getElementById("name").hasAttribute("placeholder")); // false
Both cases hide the hint text, but only the second removes the attribute. CSS or scripts using the [placeholder] selector can distinguish them.
Important details and troubleshooting
- For current states such as disabled and checked, set the DOM property directly with .prop("disabled", false) or .prop("checked", false). Attribute deletion and current-state changes should not be treated as interchangeable.
- ARIA means Accessible Rich Internet Applications. Removing an ARIA attribute can remove information used by assistive technology. To communicate a collapsed state, set aria-expanded to "false" rather than deleting it.
- Removing an onclick attribute does not remove a handler registered with .on(). Manage jQuery event handlers with the matching .off() call.
Compare the behavior with .attr() and HTML attributes, .val() and current input values.









