jQuery API

.removeAttr()

.removeAttr( attributeName ) Returns: jQuery

Description: Remove an attribute from each element in the set of matched elements.

  • version added: 1.0.removeAttr( attributeName )

    attributeNameAn attribute to remove.

The .removeAttr() method uses the JavaScript removeAttribute() function, but it has the advantage of being able to be called directly on a jQuery object and it accounts for different attribute naming across browsers.

Example:

Clicking the button enables the input next to it.

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
	<button>Enable</button>
<input type="text" disabled="disabled" value="can't edit this" />
<script>
$("button").click(function () {
  $(this).next().removeAttr("disabled")
  .focus()
  .val("editable now");
});
</script>
</body>
</html>

Demo:

Comments

  • Support requests, bug reports, and off-topic comments will be deleted without warning.

  • Please do post corrections or additional examples for .removeAttr() below. We aim to quickly move corrections into the documentation.
  • If you need help, post at the forums or in the #jquery IRC channel.
  • Report bugs on the bug tracker or the jQuery Forum.
  • Discussions about the API specifically should be addressed in the Developing jQuery Core forum.
  • carlo
    I think is like removeClass...

    .removeClass( function(index, class) )

    .removeAttr( function(index, class) )
  • SM
    Is not found this method with the function annotation in jQuery 1.4 :(