jQuery .removeAttr() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Attributes

Definition

.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.

Syntax

Start with these common calls. Keep them short and readable.

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

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

// Equivalent via .attr()
$("input").attr("title", null);
CallWhat it does
.removeAttr()Learn jQuery .removeAttr(): remove HTML attributes from matched elements, space-separated multi-attribute removal since 1.7, compare with .attr(name, null), and the IE onclick pitfall.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Select the element(s) that have the attribute.
Step 2Call .removeAttr("name") — or several names separated by spaces (1.7+).
Step 3Confirm with .attr("name") — expect undefined when gone.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

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().

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.

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.

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() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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