一個(gè)功能代碼一個(gè)個(gè)貼進(jìn)去有用,一直貼到最后一個(gè)取消功能前面的按鈕就沒(méi)有功能了,這是為什么
function color(){
??? var cc = document.getElementById("txt");
??? cc.style.color="red";
??? cc.style.backgroundColor="#000";
}
//定義"改變寬高"的函數(shù)
function change(){
??? var ch = document.getElementById("txt");
??? ch.style.width="800px";
??? ch.style.height="50px";
}
//定義"隱藏內(nèi)容"的函數(shù)
function yincang(){
??? var cg=document.getElementById("txt");
??? cg.style.display="none";
}
//定義"顯示內(nèi)容"的函數(shù)
function xianshi(){
??? var hg = document.getElementById("txt");
??? hg.style.display="block";
}
/定義"取消設(shè)置"的函數(shù)
function quxiao(){
??? var con=confirm("取消設(shè)置?");
??? if(con==true){
??????? var test=document.getElementById("txt");
???????? test.setAttribute('style','');
??? }
}
2015-07-29
這里注釋?xiě)?yīng)該是//,不是/
這里的分號(hào)的換成英文分號(hào)才行。
就是這2處引起JS代碼失效。