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