取消設(shè)置的思路問題 --我是把原來的初值一個個保存,有沒有一步到位保存所有數(shù)值的方法
我設(shè)置一個默認值,存儲原來的mychar的各項參數(shù),我試了下 默認值=mychar 然后??mychar=默認值 好像不行······
var mychar = document.getElementById("con");
? ? ? ? var 默認值
? ? ? ? 默認值.style.color = mychar.style.color;
? ? ? ? 默認值.style.backgroundColor = mychar.style.backgroundColor;
? ? ? ? 默認值.style.width = mychar.style.width;
? ? ? ? 默認值.style.height = mychar.style.height;
? ? ? ? 默認值.style.display = mychar.style.display;
2020-08-04
使用removeAttribute("style")
2020-07-26
<h2 id="con">JavaScript課程</h2>
2020-07-26
???//定義變量保存默認值
???var color = txt.style.color;
???var backgroundColor = txt.style.backgroundColor;
???var width = txt.style.width;
???var height = txt.style.height;
???var block = txt.style.display;
2020-07-26
???function cancelSet() {
????var message = confirm("取消設(shè)置?");
????if (message == true) {
?????txt.style.color = color;
?????txt.style.backgroundColor = backgroundColor;
?????txt.style.width = width;
?????txt.style.height = height;
?????txt.style.display = block;
????}
???}
2020-07-22
用confirm函數(shù)