js入門篇最后一個綜合練習,求大神指點我錯在那
?var a1=document.getElementById("txt")
? function color(){
? ? ? a1.style.color="red";
? ? ? a1.style.backgroundColor="#ccc";
? }
? function width(){
? ? ? a1.style.height="300px";
? ? ? a1.style.width="200px";
? }
? function hide(){
? ? ? a1.style.display="none";
? }
? function display(){
? ? ? a1.style.display="block";
? }
? function confirm("確定要取消設置嗎?"){
? ? ??
? ? ?
? ? a1.style.height="400px";
? ? a1.style.width="600px";
? ? a1.style.border="#333 solid 1px";
a1.style.padding="5px";
? }
2017-01-06
//定義"取消設置"的函數
function change_set(){
? ? var sse=confirm("取消設置?");
? ? if(sse==true){ ? ? ? ?
? ? ? ? var s=document.getElementById("con");
? ? ? ? s.removeAttribute("style");
var h=document.getElementById("txt");
h.removeAttribute("style");
? ? } ? else {
alert("取消了");
}?
}
2017-01-06
function confirm(){
? ? var a=confirm("是否取消設置");
? ? if(a==true){
? ? ? ? txt.style.color="auto";
? ? ? ? ?txt.style.width="600px";
? ? ? ? ? txt.style.height="400px";
? ? ? ? ? ?txt.style.display="block";
? ? ? ? ??? }
這里有個判斷,所以要加個if語句判斷,提示那里說確認了才恢復默認的,