為啥按鈕一點(diǎn)反應(yīng)都沒有啊
?<!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
? ? <input type="button" value="改變顏色" onclick="bc1()"> ?
? ? <input type="button" value="改變寬高" onclick="bc2()">
? ? <input type="button" value="隱藏內(nèi)容" onclick="bc3()">
? ? <input type="button" value="顯示內(nèi)容" onclick="bc4()">
? ? <input type="button" value="取消設(shè)置" onclick="bc5()">
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數(shù)
?var txt=document.getElementById("txt");
function bc1(){ ?
? ? txt.style.color="red";
}
//定義"改變寬高"的函數(shù)
function bc2(){?
? ? txt.style.width=100px;
? ? txt.style.height=100px;
}
//定義"隱藏內(nèi)容"的函數(shù)
function bc3(){ ??
? ? txt.style.display="none";
}
//定義"顯示內(nèi)容"的函數(shù)
function bc4(){ ? ?
? ? txt.style.display="block"
}
//定義"取消設(shè)置"的函數(shù)
function bc5(){
? ? var ask = confirm("確定重置嗎");
? ? if(ask){
? ? ? ? txt.removeAttribute("style");
? ? }
剛開始還可以改變顏色 ?后來按什么鍵都沒反應(yīng)了
2016-08-19
?txt.style.width=100px; txt.style.height=100px;。后面沒有px?
2016-08-19
一般代碼出錯(cuò)才這樣,那應(yīng)該是你改變顏色之后的代碼出錯(cuò)了,自己檢查一下標(biāo)點(diǎn)符號(hào)什么的
2016-08-19
看不出來哪里錯(cuò)了