?<!--當點擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->? ? <input type="button" value="改變顏色" onclick="ys"> ?? ? <input type="button" value="改變寬高" onclick="kd">? ? <input type="button" value="隱藏內(nèi)容" onclick="yc">? ? <input type="button" value="顯示內(nèi)容" onclick="xs">? ? <input type="button" value="取消設(shè)置" onclick="qx">? </form>? <script type="text/javascript">? var txt=document.getElementById("txt");? var con=document.getElementById("con");? function ys()??? ? {txt.style.color="red";? ? con.style.backgroundColor="blue"}//定義"改變顏色"的函數(shù)}function kd(){txt.style.width="100px";txt.style.height="100px";? ??}//定義"改變寬高"的函數(shù)function yc(){? ? txt.style.display="none"}//定義"隱藏內(nèi)容"的函數(shù)function xs(){txt.style.display="block"? ??}//定義"顯示內(nèi)容"的函數(shù)function qx(){var message=confirm("你確認要重組所有設(shè)置嗎?")? if (txt=true)? ? txt.removeAttribute('style');}? ??}//定義"取消設(shè)置"的函數(shù)? </script></body></html>
為什么我所有按鈕都不起作用呢?
慕先生9415357
2016-10-07 00:20:25