返回值:jQueryremoveAttr(attributeName)

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

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.

示例:

Clicking the button enables the input next to it.

<!DOCTYPE html>
<html>
<head>
<script src="jquery.min.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>
演示: