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