本文实例讲述了JavaScript控制按钮可用或不可用的方法。分享给大家供大家参考。具体如下:
下面的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>
希望本文所述对大家的javascript程序设计有所帮助。
本文地址:https://www.stayed.cn/item/12958
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我