Hide form after clicking submit button - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Hide form after clicking submit button

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head></head>
   <body> 
      <form name="myFirstForm" method="GET" action="?"> 
         <input type="text" name="bob"> 
         <input type="submit"> 
      </form> 
      <script>
        document.forms['myFirstForm'].addEventListener('submit', function (event) {
            // Do something with the form's data here
            this.style['display'] = 'none';
            event.preventDefault();/*w  w w.  j av  a2s.c  o  m*/
        });
    
      </script>  
   </body>
</html>

Related Tutorials