Latest web development tutorials

jQuery removeProp() 方法

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

實例

添加並移除名為"color" 的屬性:

$("button").click(function(){
var $x = $("div");
$x.prop("color","FF0000");
$x.append("The color 属性: " + $x.prop("color"));
$x.removeProp("color");
});

嘗試一下»

定義和用法

removeProp()方法移除由prop()方法設置的屬性。

注意:不要使用該方法來移除諸如style、id或checked之類的HTML屬性。請使用removeAttr()方法代替。


語法

$(selector).removeProp(property)

参数 描述
property 规定要移除的属性的名称。


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