Disable a button after clicking - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button


Disable a button after clicking

Demo Code

ResultView the demo in separate window

    function myFunction() {// w ww .j  a v  a2s .c  o  m
      var b = document.getElementById('result');
      b.innerHTML = 'You pressed the button.';
      document.getElementById('button1').disabled = 'disabled';
      <button onclick="myFunction()" id="button1">Press this</button> 
      <div id="result">
         You haven't pressed the button yet.

Related Tutorials