Call function in input button - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Call function in input button

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script>
function go(){//from ww w. jav a2s  . com
            var array = new Array();
            array[0] = "Red";
            array[1] = "Blue";
            array[3] = "Green";
            for (var i=0; i < array.length; i++){
                document.write("<li>" + array[i] + "<br />");
            }
}
        
      </script> 
   </head> 
   <body> 
      <input type="button" onclick="go()" value="Display JS Array">  
   </body>
</html>

Related Tutorials