How to repeat div element n times in HTML?

前端 未结 5 1122
时光说笑
时光说笑 2020-12-09 21:44

How can I duplicate a

so there are n copies using JavaScript?

Start with 1:

5条回答
  •  無奈伤痛
    2020-12-09 22:43

    Take a look at the fiddle to get your result

    https://jsfiddle.net/dcpg4v1c/

    $(document).ready(function(){
       for(var i = 0; i< 5; i++)
         $("#dvMain").append("
    Test
    "); });
    
    

提交回复
热议问题