Javascript examples for DOM HTML Element:Input Button
Disable a button with setAttribute("disabled") and removeAttribute("disabled")
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <button id="btn1" onclick="disbtn(this.id);">button 1</button> <script type="text/javascript"> function disbtn(id) {// w ww . j a v a2s .co m if ( id == "btn1" ) { document.getElementById(id).setAttribute("disabled","disabled"); } else { document.getElementById(id).removeAttribute("disabled"); } } </script> </body> </html>