標籤:body 修改 asc java sub remove for round box
如果<button>標籤在<form>中不加type=“button”,那麼預設含義是“submit”。
<button>標籤裡面disabled屬性使其不可用,常見javascript修改disabled屬性執行個體:(a鍵b鍵互相撕逼)
<style> #a,#b { height:30px; width:70px; background:yellow; box-sizing:border-box; } </style> </head> <body> <button type="button" id="a" onclick="an()" >會變色</button> <button type="button" id="b" onclick="bn()" >會變色</button><script>function bn(){if(document.getElementById("b").disabled!="true"){document.getElementById("b").disabled="true";document.getElementById("b").style.background="gray";document.getElementById("a").removeAttribute("disabled");document.getElementById("a").removeAttribute("style");}else{document.getElementById("a").disabled="true";document.getElementById("a").style.background="gray";document.getElementById("b").removeAttribute("disabled");document.getElementById("b").removeAttribute("style");}}function an(){if(document.getElementById("a").disabled!="true"){document.getElementById("a").disabled="true";document.getElementById("a").style.background="gray";document.getElementById("b").removeAttribute("disabled");document.getElementById("b").removeAttribute("style");}else{document.getElementById("b").disabled="true";document.getElementById("b").style.background="gray";document.getElementById("a").removeAttribute("disabled");document.getElementById("a").removeAttribute("style");}}</script></body>
HTML <button>標籤