?
This document uses PHP Chinese website manual Release
用來刪除由.prop()方法設(shè)置的屬性集
隨著一些內(nèi)置屬性的DOM元素或window對象,如果試圖將刪除該屬性,瀏覽器可能會(huì)產(chǎn)生錯(cuò)誤。jQuery第一次分配undefined值的屬性,而忽略了瀏覽器生成的任何錯(cuò)誤
要?jiǎng)h除的屬性名
設(shè)置一個(gè)段落數(shù)字屬性,然后將其刪除。
<p> </p>
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.