Javascript examples for DOM:Element cloneNode
Clone DOM node
<html> <head></head> <body> <div id="main"> <button id="mybtn">click me for index </button> </div> <script> var myarray = [2,4,6,5,5];/*from w w w. jav a 2 s .c om*/ for(var i=0; i<= myarray.length; i++){ var allBtn = document.getElementById("mybtn").cloneNode(true); document.body.appendChild(allBtn); } </script> </body> </html>