jQuery .removeAttr() Method

Beginner
6 min read
Updated: Oct 2026
5 examples
Live preview

What Is .removeAttr()?

.removeAttr() (since 1.0) removes an HTML attribute from every matched element. Since 1.7, you can pass a space-separated list of attribute names.

Remember
// Remove one
$("input").removeAttr("title");

// Remove several (jQuery 1.7+)
$("#card").removeAttr("title data-role");

// Equivalent via .attr()
$("input").attr("title", null);
NeedUse
Remove HTML attribute.removeAttr(name)
Same via setter.attr(name, null)
Live form / property state.prop()
Custom jQuery property.removeProp()
CSS classes.removeClass()

How to Use .removeAttr()

Select elements, pass the attribute name(s), and chain if needed.

  1. Select the element(s) that have the attribute.
  2. Call .removeAttr("name") — or several names separated by spaces (1.7+).
  3. Confirm with .attr("name") — expect undefined when gone.
  4. Prefer .prop("onclick", null) to clear inline handlers in legacy IE.
  5. Use .removeClass() for class names, not .removeAttr("class"), in most apps.
PieceRequired?Role
attributeNameYesOne name, or space-separated list since 1.7
Return—Same jQuery object (chainable)
Scope—Every matched element
Native under the hood—removeAttribute() with jQuery naming fixes

Pseudocode

Pseudocode
call .removeAttr(attributeName)

names = split attributeName on spaces

for each matched element:
    for each name in names:
        removeAttribute(name)

return the jQuery collection

Cheat Sheet

Keep these facts handy when stripping attributes from markup.

TopicDetail
SincejQuery 1.0 · multi-name list since 1.7
vs .attr(name, null)Equivalent removal
Missing attributeSafe — no error if already absent
After removal.attr(name) → undefined (1.6+)
IE onclickUse .prop("onclick", null)
ClassesPrefer .removeClass()
Native propertiesDo not use .removeProp() on checked/disabled

Live Preview

Toggle or strip attributes on the sample input — same APIs as the examples below.

Sample element: the text input below. Hover it when title is set to see the tooltip.

Result
Ready — pick an action and click Run.

jQuery Examples

Short, copy-ready snippets. Prefer .removeAttr() when removal is the goal.

Example 1 — Official Toggle Title

Add and remove title on an input — the documented demo pattern.

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").text("input title is now " + input.attr("title"));
});
Try It Yourself

How It Works

  1. Remember. Store the original title once.
  2. Compare. If it still matches, remove it.
  3. Restore. Otherwise set it back with .attr().
  4. Log. Show the current getter result after each click.

Example 2 — Remove One Attribute

Strip a single attribute from every matched element.

jQuery
$("#hint").removeAttr("title");
$("#out").text("title → " + $("#hint").attr("title"));
Try It Yourself

How It Works

  1. Select. Target the element that has the attribute.
  2. Remove. .removeAttr("title") deletes it.
  3. Safe. Calling again when absent does nothing harmful.
  4. Check. Getter returns undefined after removal (1.6+).

Example 3 — Remove Several Attributes

Since jQuery 1.7, pass a space-separated list of names.

jQuery
$("#card").removeAttr("title data-role");

$("#out").text(
  "title=" + $("#card").attr("title") +
  ", data-role=" + $("#card").attr("data-role")
);
Try It Yourself

How It Works

  1. List. Split names on spaces.
  2. Loop. jQuery removes each name on every match.
  3. One call. Cleaner than chaining several removers.
  4. Verify. Both getters return undefined.

Example 4 — .removeAttr() vs .attr(name, null)

Both remove the attribute — pick the form that reads clearest in context.

jQuery
$("#a").removeAttr("title");
$("#b").attr("title", null);

$("#out").text(
  "a=" + $("#a").attr("title") +
  ", b=" + $("#b").attr("title")
);
Try It Yourself

How It Works

  1. removeAttr. Dedicated remover — intent is obvious.
  2. attr null. Same effect via the attribute setter.
  3. Result. Both getters show undefined.
  4. Choose. Use either; stay consistent in a file.

Example 5 — Clear Inline onclick with .prop()

Official guidance for IE: clear the property, not only the attribute.

jQuery
var $btn = $("#go");

$btn.prop("onclick", null);
$("#out").text(
  "onclick property: " + $btn[0].onclick
);
Try It Yourself

How It Works

  1. Problem. .removeAttr("onclick") fails in some IE versions.
  2. Fix. Set the live property to null with .prop().
  3. Check. Native element.onclick becomes null.
  4. Prefer. Use .on() / .off() for modern handlers.

Edge Cases & Pitfalls

Watch for these when stripping attributes.

IE

onclick needs .prop()

Do not rely on .removeAttr("onclick") in IE 8–11. Use .prop("onclick", null).

class

Prefer .removeClass()

.removeAttr("class") wipes the whole attribute. Class helpers remove names safely.

boolean

Removing disabled ≠ enabling via property alone

For live enable/disable, set .prop("disabled", false). Attribute and property can diverge.

native

Do not .removeProp() native properties

.removeProp() is for custom properties. Reset natives with .prop(name, false) instead.

Browser Support

.removeAttr() has been part of jQuery since 1.0. Space-separated multi-attribute removal since 1.7. Works wherever your loaded jQuery build runs.

✓ Stable · jQuery 1.0+

jQuery .removeAttr()

Universal across browsers that run your jQuery version. Prefer current jQuery 3.x+; use .prop for IE onclick edge cases.

100% jQuery core
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
.removeAttr() Universal

Bottom line: Safe for everyday apps. Use .removeAttr() for HTML attributes; clear onclick with .prop in legacy IE.

Performance Notes

ApproachCostBest for
One .removeAttr()CheapTypical UI cleanup
Space-separated listCheapRemoving a few related attrs
Huge selections in a loopCostlyOne selection + one call instead

Removal is inexpensive. Prefer one selection and a multi-name call over repeated queries inside tight loops.

Key Takeaways

  • Role: remove HTML attributes from every matched element.
  • 1.7+: space-separated names remove several at once.
  • Alias: .attr(name, null) does the same removal.
  • IE: clear onclick with .prop("onclick", null).

One line: .removeAttr() strips HTML attributes — use .prop() when you need to clear a live property like onclick.

Frequently Asked Questions

.removeAttr() removes one or more HTML attributes from every matched element. It wraps native removeAttribute() with jQuery chaining and cross-browser attribute naming. Available since jQuery 1.0.
They both remove the attribute. Prefer .removeAttr("title") when removal is the intent, or .attr("title", null) when you already use .attr() nearby.
Yes. Since jQuery 1.7, pass a space-separated list: .removeAttr("title data-role"). Each name is removed from every matched element.
Yes. It removes the attribute(s) from every element in the collection and returns the jQuery object for chaining.
In IE 8, 9, and 11, removing inline onclick with .removeAttr() is unreliable. Clear the property instead: .prop("onclick", null).
Prefer .removeClass() for CSS classes. Use .removeAttr("class") only when you need to strip the entire class attribute from the markup.

Next: .removeProp() Method

Learn when to remove custom properties — and why not to use it on natives.

.removeProp() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful