hide a <div> and show only when a <textarea> has focus - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

hide a <div> and show only when a <textarea> has focus

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <div id="divID">
          Menu /* w ww  .  j  a  va 2 s  .  c  om*/
      </div> 
      <textarea onfocus="hideDiv()" onblur="showDiv()">
         ABC
</textarea> 
      <script type="text/javascript">
function hideDiv(){
    document.getElementById("divID").style.display = 'none';
}
function showDiv(){
    document.getElementById("divID").style.display = 'block';
}

      </script>  
   </body>
</html>

Related Tutorials