<style type="text/css">body{font-size:12px;}#txt{? ? height:400px;? ? width:600px; border:#333 solid 1px; padding:5px;}p{ line-height:18px; text-indent:2em;}</style></head><body>? <h2 id="con">JavaScript課程</H2>? <div id="txt">?? ? ......? </div>? <form>? <!--當點擊相應按鈕,執行相應操作,為按鈕添加相應事件--><input type="button" value="改變顏色" onClick="changecolor()"> ??<input type="button" value="改變寬高" onClick="changesize()" >? ?<input type="button" value="隱藏內容" onClick="hidetxt()">? <input type="button" value="顯示內容" onClick="shoutet()" >? ? <input type="button" value="取消設置" onClick="rset()" >? </form>? <script type="text/javascript">var myh=document.getElementById("con");var mydiv=document.getElementById("txt");?function changecolor(){mydiv.style.color="red";//定義"改變顏色"的函數}function changesize(){mydiv.style.width=300px;//定義"改變寬高"的函數mydiv.style.height=400px;}function hidetxt(){mydiv.style.display="none";//定義"隱藏內容"的函數}function showtxt(){mydiv.style.display="block";//定義"顯示內容"的函數}function rset(){var message=confirm("是否取消設置");//定義"取消設置"的函數if(message==true){? ?mydiv.removeAttribute=("style");}else{? ??}}? </script>
改變顏色和寬度兩個按鈕始終沒反應,眼睛要瞅瞎了,是哪里出了問題嗎求大神指點
彈指
2017-08-17 10:44:19