Set default value null to input text box - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Set default value null to input text box

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
function Hello()/*  ww w .j a v a 2s .  c  o m*/
{
    var a=document.getElementById('nm').value;
    console.log(a);
    document.getElementById('nm').value=null;
    console.log(document.getElementById('nm').value);
}

      </script> 
   </head>
   <body>
       Name : 
      <input type="text" name="nm" id="nm"> 
      <input type="button" value="CLick" onclick="Hello()">   
   </body>
</html>

Related Tutorials