Javascript examples for DOM HTML Element:Span
Creating loop and create element
<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>