Javascript examples for DOM:Document getElementById
Document.getElementByID and for loop
<html> <head></head> <body> <div id="main"> <button id="mybtn">click me for index </button> </div> <script> var myarray = [2,4,6,5,5];// ww w .j av a 2 s . co m for(var i=0; i<= myarray.length; i++){ var allBtn = document.getElementById("mybtn").cloneNode(true); document.body.appendChild(allBtn); } </script> </body> </html>