.removeAttr()

.removeAttr( attributeName ) 返回: jQuery

描述: 为匹配的元素集合中的每个元素中移除一个属性。

  • version added: 1.0.removeAttr( attributeName )

    attributeName要移除的属性名

.removeAttr() 方法使用原生的 JavaScript removeAttribute() 函数,但是它的优点是能够直接被jQuery对象访问调用。而且具有良好的浏览器兼容性。

举例:

点击按钮是文本框您够使用:

<!DOCTYPE html>
<html>
<head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/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>

Demo:

jQuery 1.6 API 中文版Clove整理、修订