Latest web development tutorials

jQuery removeAttr() 方法

jQuery HTML/CSS 方法 jQuery HTML/CSS方法

實例

從所有的<p> 元素移除樣式屬性:

$("button").click(function(){
$("p").removeAttr("style");
});

嘗試一下»

定義和用法

removeAttr() 方法從被選元素移除一個或多個屬性。


語法

$(selector).removeAttr(attribute)

参数 描述
attribute 必需。规定要移除的一个或多个属性。如需移除若干个属性,请使用空格分隔属性名称。


實例

更多實例

從被選元素移除若干個屬性
如何從被選元素移除id 和class 屬性。


jQuery HTML/CSS 方法 jQuery HTML/CSS方法