源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> </head> <body> <form> 按鈕: <input type="button" id="firstbtn" value="OK"> <input type="button" id="secondbtn" value="OK"> </form> <p>點擊下面的按鈕取消上面的第一個按鈕。</p> <button onclick="disableElement()">取消按鈕</button> <script> function disableElement(){ document.getElementById("firstbtn").disabled=true; } </script> </body> </html>
運行結果