Hide and show an element with button click - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Hide and show an element with button click

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head></head>
   <body translate="no"> 
      <div id="theMessage">
         Here goes your form
      </div> 
      <button onclick="showMsg();">show</button> 
      <button onclick="hideMsg();">hide</button> 
      <script>
      var element = document.getElementById("theMessage");
function showMsg(){/*from w ww.  j a  v a2s .  c o  m*/
    element.style.visibility = "visible";
}
function hideMsg() {
      element.style.visibility = "hidden";
}
    
      </script>  
   </body>
</html>

Related Tutorials