Set text box value to null - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Set text box value to null

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <h1>Hello World</h1> 
      <input type="text" value="hello" name="group">
      <br> 
      <input type="text" value="hello" name="group">
      <br> 
      <input type="text" value="hello" name="group">
      <br> 
      <br> 
      <button onclick="myFunction()">Try it</button> 
      <script>
function myFunction() {//from   www  .j  a v  a 2  s. c  om
    var x = document.getElementsByName("group");
    var i;
    for (i = 0; i < x.length; i++) {
       x[i].setAttribute("value","");
        }
    }

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

Related Tutorials