Creating loop and create element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Span


Creating loop and create element

Demo Code

ResultView the demo in separate window

      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <div id="myHTMLWrapper"> 
  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


Related Tutorials