This JavaScript program shows how to disable and enable a button by using the onclick event and handler function.
<!DOCTYPE html> <html> <head> <title>XoaX.net's Javascript</title> <script type="text/javascript"> function DisableButton() { document.getElementById('idAlert').disabled = !(document.getElementById('idAlert').disabled); } function ShowAlert() { alert("I am enabled."); } </script> </head> <body> <button onclick="DisableButton()">The Disabler</button> <button id="idAlert" onclick="ShowAlert()">Alert</button> </body> </html>
© 20072024 XoaX.net LLC. All rights reserved.