The .removeAttr() method removes HTML attributes from matched elements. This tutorial covers the single- and multi-attribute API (space-separated since 1.7), equivalence with .attr(name, null), comparisons with .removeProp() and .removeClass(), the IE onclick caveat, and five official and practical jQuery demos.
01
Remove one
Single attribute
02
Remove many
Space-separated
03
All matches
Every element
04
vs .attr(null)
Same effect
05
IE onclick
Use .prop()
06
Since 1.0
Core API
Fundamentals
Introduction
HTML attributes decorate elements in markup — title for tooltips, alt on images, required on form fields, and aria-* for accessibility. When JavaScript needs to strip those attributes at runtime, jQuery provides .removeAttr().
Available since jQuery 1.0, .removeAttr() wraps the native removeAttribute() function with two key advantages: it operates on a jQuery collection (removing from every matched element) and it accounts for inconsistent attribute naming across browsers. Since jQuery 1.7, a single call can remove multiple attributes by passing a space-separated list.
Removing an attribute is equivalent to calling .attr(name, null). For live DOM properties — especially inline event handlers like onclick in older Internet Explorer — reach for .prop(name, null) instead.
Concept
Understanding the .removeAttr() Method
Given a jQuery object representing one or more DOM elements, .removeAttr(attributeName) removes the named attribute from each element in the set. The method returns the original jQuery object for chaining — for example, $("input").removeAttr("title").addClass("clean").
Attributes live in HTML markup; properties are live DOM state. Removing an attribute does not always reset the corresponding property — the IE onclick case is the most common pitfall. For CSS classes, prefer .removeClass() over stripping the entire class attribute unless you need to remove the attribute itself.
💡
Beginner Tip
$("input").removeAttr("title") removes the title attribute from every matched input. After removal, .attr("title") returns undefined — hover tooltips disappear because the attribute no longer exists in markup.
Foundation
📝 Syntax
jQuery .removeAttr() accepts one argument form:
Remove attribute(s) — since 1.0 (multi-name since 1.7)
jQuery
.removeAttr( attributeName )
attributeName — a single attribute name, or since jQuery 1.7 a space-separated list of attributes to remove.
Removes the attribute from every matched element.
Returns the original jQuery object (for chaining).
Return value
Always returns the original jQuery object — enabling method chaining.
Equivalent removal with .attr()
Passing null as the value to .attr() removes the attribute the same way:
jQuery
// These are equivalent
$("div").removeAttr("title");
$("div").attr("title", null);
WARNING: inline onclick in IE
Removing an inline onclick handler with .removeAttr() does not work reliably in Internet Explorer 8, 9, and 11. Use .prop() instead:
jQuery
// Correct — clears the live onclick property
$element.prop("onclick", null);
console.log("onclick property: ", $element[0].onclick);
// Unreliable in IE 8, 9, 11
// $element.removeAttr("onclick");
Official jQuery API example
jQuery
var inputTitle = $( "input" ).attr( "title" );
$( "button" ).on( "click", function() {
var input = $( this ).next();
if ( input.attr( "title" ) === inputTitle ) {
input.removeAttr( "title" );
} else {
input.attr( "title", inputTitle );
}
$( "#log" ).html( "input title is now " + input.attr( "title" ) );
});
With title: hover shows tooltip, log shows "Hover me for tooltip"
After removeAttr: title is undefined, no tooltip on hover
How It Works
The code stores the original title value, then toggles between .removeAttr("title") and .attr("title", inputTitle). After removal, .attr("title") returns undefined.
Example 2 — Remove Multiple Attributes (Space-Separated, 1.7+)
Pass a space-separated list to strip title, data-role, and data-version in one call.
After removeAttr:
title: undefined
data-role: undefined
data-version: undefined
How It Works
Since jQuery 1.7, a single string with space-separated attribute names removes each one from every matched element. This is cleaner than three separate .removeAttr() calls.
📈 Practical Patterns
Equivalence, validation cleanup, and IE-safe event handler removal.
Example 3 — Equivalent to .attr(name, null)
Compare .removeAttr('alt') with .attr('title', null) — both delete attributes from markup.
After .removeAttr('alt'): alt is undefined
After .attr('title', null): title is undefined
Both methods remove attributes from the DOM
How It Works
jQuery treats null as a removal signal in .attr(). Choose .removeAttr() when removal is the explicit intent; use .attr(name, null) when you already use .attr() for get/set in the same function.
Example 4 — Remove aria-invalid and required After Validation
Strip validation-related attributes once the user provides valid input.
Input border turns green (.ok class added)
aria-invalid and required removed from markup
Attribute count drops; browser no longer treats field as required
How It Works
Removing required stops HTML5 constraint validation on submit. Removing aria-invalid clears the accessibility error state. Chain .addClass() before .removeAttr() for a single fluent call.
Example 5 — Clear Inline onclick With .prop(), Not .removeAttr()
Internet Explorer 8, 9, and 11 ignore .removeAttr('onclick') — use .prop('onclick', null) instead.
Before: clicking button shows alert (inline onclick)
After .prop('onclick', null): onclick property is null, no alert
.removeAttr('onclick') may leave handler active in IE
How It Works
Inline event handlers are live DOM properties, not just markup attributes. Setting the property to null via .prop() clears the handler reliably across browsers including legacy IE.
Applications
🚀 Common Use Cases
Toggle tooltips — $("input").removeAttr("title") to hide hover text after the user dismisses a hint.
Lazy-load cleanup — $("img").removeAttr("data-src") after copying the URL into src.
Form validation reset — $("input").removeAttr("aria-invalid required") when input becomes valid.
Strip deprecated data attrs — $(".widget").removeAttr("data-version data-role") after migration.
Disable link navigation — $("a.disabled").removeAttr("href") to prevent clicks without removing the element.
Accessibility cleanup — $("[aria-hidden]").removeAttr("aria-hidden") when content becomes visible.
🧠 How .removeAttr() Removes Attributes
1
Match elements
jQuery object holds one or more DOM nodes.
Input
2
Parse attribute names
Single name or space-separated list (since 1.7).
Args
3
Call removeAttribute()
jQuery normalizes naming and removes from each element.
DOM
4
🏷
jQuery object returned
Attribute gone from every match — chain further methods freely.
Important
📝 Notes
Available since jQuery 1.0 — space-separated multi-attribute removal since 1.7.
Removes attributes from every matched element; returns the jQuery object for chaining.
Do not use .removeProp() on native DOM properties — it is for jQuery-added properties only.
Prefer .removeClass() over .removeAttr('class') for CSS class manipulation.
Compatibility
Browser Support
.removeAttr() has been part of jQuery since 1.0+. Multi-attribute removal via a space-separated string arrived in 1.7+. jQuery normalizes cross-browser attribute naming — the main reason to prefer it over raw removeAttribute() in legacy projects.
✓ jQuery 1.0+
jQuery .removeAttr()
Supported in jQuery 1.x, 2.x, 3.x, and 4.x across all modern browsers and IE with supported jQuery builds. Native equivalent: element.removeAttribute() — jQuery adds collection semantics, multi-name removal, and cross-browser normalization. Exception: inline onclick removal in IE requires .prop('onclick', null).
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.removeAttr()Universal
Bottom line: Safe in any jQuery project. Use .removeAttr() for HTML attributes; .prop(null) for inline event handlers in IE.
Wrap Up
Conclusion
The jQuery .removeAttr() method removes HTML attributes from every matched element. It is the dedicated removal API — cleaner than .attr(name, null) when stripping attributes is the sole goal, and it supports removing multiple attributes in one call since jQuery 1.7.
Remember the official demo: toggle a title attribute on an input with .removeAttr("title") and .attr("title", value). For inline onclick handlers in legacy IE, use .prop("onclick", null) instead. Chain freely — .removeAttr("data-old").addClass("migrated").
Use .removeClass() for CSS class changes instead of stripping class
Chain after removal — .removeAttr('title').addClass('clean')
❌ Don’t
Use .removeAttr('onclick') expecting it to work in IE 8, 9, or 11
Call .removeProp() on native DOM properties like checked
Use .removeAttr('class') when .removeClass() is sufficient
Assume removing an attribute resets the corresponding live property
Remove required without also updating visual validation state
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about .removeAttr()
Strip markup attributes — not live properties.
5
Core concepts
-101
One attr
Since 1.0
API
-N02
Many attrs
Since 1.7
API
null03
= .attr(null)
Equivalent
Compare
all04
Every match
Not first only
Behavior
.prop05
IE onclick
Use .prop()
Caveat
❓ Frequently Asked Questions
.removeAttr() removes one or more HTML attributes from every matched element. It calls the native removeAttribute() function under the hood but works on a jQuery collection and normalizes attribute naming across browsers. Available since jQuery 1.0.
They are equivalent for removal. .removeAttr('title') and .attr('title', null) both delete the title attribute from every matched element. Use .removeAttr() when removal is the sole intent, or .attr(name, null) when you already use .attr() for get/set in the same block.
Yes. Since jQuery 1.7, pass a space-separated list: .removeAttr('title data-role data-version'). jQuery removes each named attribute from every element in the matched set in one call.
Yes. Unlike .attr() getters (which read the first element only), .removeAttr() is a setter-style operation that removes the attribute from every element in the jQuery collection and returns the same jQuery object for chaining.
Removing an inline onclick event handler with .removeAttr() does not achieve the desired effect in IE 8, 9, and 11. Use .prop('onclick', null) instead to clear the live onclick property. See Example 5 and the .prop() tutorial for details.
Prefer .removeClass() for CSS class manipulation because it handles multiple classes, partial removal, and avoids quoting the reserved word class. Use .removeAttr('class') only when you need to strip the entire class attribute from markup entirely.
Did you know?
Before jQuery 1.7, removing multiple attributes required separate .removeAttr() calls — one per attribute. The space-separated list feature mirrors a similar convenience in CSS selectors and reduces boilerplate when cleaning up data-* attributes after a widget initializes. The equivalence with .attr(name, null) exists because jQuery’s attribute module treats null as a deletion signal in both the setter and the dedicated removal method.