為什么取消設置不行
//定義"取消設置"的函數
function settings(){
? ? var message=confirm("還原設置?");
? ? if(messge){
? ? ? ? document.getElementById("txt").removeAttribute("style");
? ? }
? ? else{
? ? ? ??
? ? }
}
//定義"取消設置"的函數
function settings(){
? ? var message=confirm("還原設置?");
? ? if(messge){
? ? ? ? document.getElementById("txt").removeAttribute("style");
? ? }
? ? else{
? ? ? ??
? ? }
}
2018-11-26
舉報
2018-11-27
你的方法是沒有問題的可能問題出在了你綁定事件上面,有可能你的事件綁定錯了。
2018-11-27
getAttribute和removeAttribute不能直接操作“style”吧;
#txt的默認樣式應該是color:inherit;width:400px;heihgt:600px;display:block;確認取消設置就一一恢復設置對應的屬性;
如果要擴展,就聲明變量分別存儲div的初始屬性,點擊取消設置再將初始值賦值給div