課程
/前端開(kāi)發(fā)
/JavaScript
/JavaScript入門(mén)篇
把所以屬性都重置怎么辦?
2016-12-01
源自:JavaScript入門(mén)篇 4-1
正在回答
兩種辦法
第一種,依次把改動(dòng)過(guò)的屬性全部賦初始值
? ? ? ? ? ? object.style.color = "black";
? ? ? ? ? ? object.style.backgroundColor = "white";
? ? ? ? ? ? object.style.width = orignWidth;
? ? ? ? ? ? object.style.height = orignHeight;
? ? ? ? ? ? object.style.display = "block";
第二種,因?yàn)楦牡亩际莝tyle下的屬性,可用語(yǔ)句:
object.removeAttribute('style');
上文中的object 替換成你 getElementById 賦給的變量名稱(chēng)就行
for(var i= xxx.attributes.length-1;i>=0;i--){ ? ?xxx.removeAttribute(xxx.attributes[i].nodeName)}
舉報(bào)
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門(mén)
1 回答取消設(shè)置屬性
2 回答設(shè)置字體屬性
4 回答取消設(shè)置屬性
1 回答設(shè)置屬性沒(méi)效果
1 回答我的屬性設(shè)置不出來(lái)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-12-01
兩種辦法
第一種,依次把改動(dòng)過(guò)的屬性全部賦初始值
? ? ? ? ? ? object.style.color = "black";
? ? ? ? ? ? object.style.backgroundColor = "white";
? ? ? ? ? ? object.style.width = orignWidth;
? ? ? ? ? ? object.style.height = orignHeight;
? ? ? ? ? ? object.style.display = "block";
第二種,因?yàn)楦牡亩际莝tyle下的屬性,可用語(yǔ)句:
object.removeAttribute('style');
上文中的object 替換成你 getElementById 賦給的變量名稱(chēng)就行
2016-12-01
for(var i= xxx.attributes.length-1;i>=0;i--){
? ?xxx.removeAttribute(xxx.attributes[i].nodeName)
}