.removeAttr()
.removeAttr( attributeName ) 返回: jQuery
描述: 為匹配的元素集合中的每個(gè)元素中移除一個(gè)屬性。
-
version added: 1.0.removeAttr( attributeName )
attributeName要移除的屬性名
.removeAttr()
方法使用原生的 JavaScript removeAttribute()
函數(shù),但是它的優(yōu)點(diǎn)是能夠直接被jQuery對象訪問調(diào)用。而且具有良好的瀏覽器兼容性。
舉例:
點(diǎn)擊按鈕是文本框您夠使用:
<!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>