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