removeProp(name)
返回值
jQuery
概述
用来删除由.prop()方法设置的属性集
随着一些内置属性的DOM元素或window对象,如果试图将删除该属性,浏览器可能会产生错误。jQuery第一次分配undefined值的属性,而忽略了浏览器生成的任何错误
参数
示例
示例一
描述:设置一个段落数字属性,然后将其删除。
HTML代码
<p> </p>
jQuery 代码
var $para = $("p");
$para.prop("luggageCode", 1234);
$para.append("The secret luggage code is: ", String($para.prop("luggageCode")), ". ");
$para.removeProp("luggageCode");
$para.append("Now the secret luggage code is: ", String($para.prop("luggageCode")), ". ");
结果
The secret luggage code is: 1234. Now the secret luggage code is: undefined.