<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>? <!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件--><input type="button" value="改變顏色" onClick="changecolor()"> ??<input type="button" value="改變寬高" onClick="changesize()" >? ?<input type="button" value="隱藏內(nèi)容" onClick="hidetxt()">? <input type="button" value="顯示內(nèi)容" onClick="shoutet()" >? ? <input type="button" value="取消設(shè)置" onClick="rset()" >? </form>? <script type="text/javascript">var myh=document.getElementById("con");var mydiv=document.getElementById("txt");?function changecolor(){mydiv.style.color="red";//定義"改變顏色"的函數(shù)}function changesize(){mydiv.style.width=300px;//定義"改變寬高"的函數(shù)mydiv.style.height=400px;}function hidetxt(){mydiv.style.display="none";//定義"隱藏內(nèi)容"的函數(shù)}function showtxt(){mydiv.style.display="block";//定義"顯示內(nèi)容"的函數(shù)}function rset(){var message=confirm("是否取消設(shè)置");//定義"取消設(shè)置"的函數(shù)if(message==true){? ?mydiv.removeAttribute=("style");}else{? ??}}? </script>
改變顏色和寬度兩個(gè)按鈕始終沒(méi)反應(yīng),眼睛要瞅瞎了,是哪里出了問(wèn)題嗎求大神指點(diǎn)
彈指
2017-08-17 10:44:19