Handle onfocus event for input text box - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Handle onfocus event for input text box

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function hideValue(that, value) {
    if (that.value === value) {/*from w ww .j  a  v a2  s .co m*/
        that.value = '';
    }
}

      </script> 
   </head> 
   <body> 
      <input onfocus="hideValue(this, 'First Name')" type="text" name="first_name" value="First Name">  
   </body>
</html>

Related Tutorials