JS重置原來CS樣式
有沒有人用這個可以將樣式實現恢復原始值啊,removeAttribute("style")不是刪除style屬性的么。參考大家的代碼,除了直接在這個函數再次重新設置原來的屬性,大部分人好像都是使用以下代碼,但是我一直沒辦法實現重置啊,有沒有大神教一下怎么使用removeAttribute()重置原來樣式的,謝謝! function reset(){ ? ? var message=confirm("你確定要重置所有設置么?"); ? ? ? ?if(message==true){ ? ? ? ? ? ?txt.removeAttribute("style"); } ? ? }
2017-01-04
var oldStyle=txt.getAttribute("style"); //獲得舊的style屬性
txt.removeAttribute("style"); //刪除掉屬性
txt.setAttribute("style",oldStyle); //恢復到舊的style屬性
2017-01-03
直接重載頁面 document.location.reload();
2017-01-03
線定義className=“yourstyle”,.yourstyle{你需要的式樣}, ? ? ?然后reset()去掉className就行了