為什么我寫的取消設置沒用呢
為什么我寫的取消設置沒用呢,為什么取消不了呢,有沒有大神會啊
<!--當點擊相應按鈕,執(zhí)行相應操作,為按鈕添加相應事件-->
? ? <input type="button" value="改變顏色" ?onclick="changeColor()"> ?
? ? <input type="button" value="改變寬高" onclick="changeWidth()" >
? ? <input type="button" value="隱藏內容" onclick="dis()" >
? ? <input type="button" value="顯示內容" onclick="show()" >
? ? <input type="button" value="取消設置" ?onclick="co()">
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數(shù)
function changeColor(){
? ? var col=document.getElementById("txt");
? ? col.style.color="red";
? ? col.style.backgroundcolor="#F00";
}
//定義"改變寬高"的函數(shù)
function changeWidth(){
? ? var wi=document.getElementById("txt");
? ? wi.style.width="300px";
? ? wi.style.height="600px";
? ??
}
//定義"隱藏內容"的函數(shù)
function dis(){
? ? var di=getElementById("txt");
? ? di.style.display="none";
? ??
}
//定義"顯示內容"的函數(shù)
function show(){
? ? var disp=getElementById("txt");
? ? disp.style.display="block"; ? ?
? ??
}
//定義"取消設置"的函數(shù)
function co(){
? ? var t=confirm("你確定取消設置嗎?");
if(t=="true"){
? ??
? ? txt.removeAttribute('style');
}
}
? </script>
2016-11-27
true不要打雙引號