下面的JS代码通过按钮对象的disabled属性控制按钮是否可用
<!DOCTYPE html> <html> <body> <form> Buttons: <input type="button" id="firstbtn" value="OK"> <input type="button" id="secondbtn" value="OK"> </form> <p>Click the button below to disable the first button above.</p> <button onclick="disableElement()">Disable button</button> <script> function disableElement() { document.getElementById("firstbtn").disabled=true; } </script> </body> </html>