返回值:jqueryremoveprop(name)
概述
用来删除由.prop()方法设置的属性集
随着一些内置属性的dom元素或window对象,如果试图将删除该属性,浏览器可能会产生错误。jquery第一次分配undefined值的属性,而忽略了浏览器生成的任何错误
参数
propertynamestringv1.6
要删除的属性名
示例
描述:
设置一个段落数字属性,然后将其删除。
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.