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