Creating loop and create element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Span

Description

Creating loop and create element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <div id="myHTMLWrapper"> 
      </div> 
      <script>
  var wrapper = document.getElementById("myHTMLWrapper");
  var myHTML = '';
  for (var i = 0; i < 10; i++) {
    myHTML += '<span class="test">Testing out my script! loop #' + (i + 1) + '</span><br/><br/>';
  }/*  w w  w  . j av a  2  s. c o  m*/
  wrapper.innerHTML = myHTML

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

Related Tutorials