Repeat HTML Code 9 Times in JavaScript | jQuery Example
"To repeat the HTML code 9 times within the class "paging-content", you can use a loop to append the HTML code multiple times. Here's an example using JavaScript:\n\njavascript\nvar htmlCode = '<div class=\"qq33w qqflr qqinrow qq_product_in_list qq_shimmer\" rel=\"nofollow\> <div class=\"qq_inlist_pad\> <a class=\"shlink\> <div class=\"qq_product_img_inlist\" style=\"\> </div> </a> <div class=\"qq_product_list_details\> <a href=\"#\><h3>loading text</h3> <h4> loading text loading text loading text loading text loading text loading text loading text loading text loading text loading text loading text </h4> </a> </div> </div> </div>';\n\nvar repeatedHTML = '';\nfor (var i = 0; i < 9; i++) {\n repeatedHTML += htmlCode;\n}\n\n$('.paging-content').html(repeatedHTML);\n\n\nThis code creates a variable htmlCode that stores the HTML code you provided. It then loops 9 times, adding the HTML code to the repeatedHTML variable each time. Finally, it sets the html of the element with the class "paging-content" to the repeatedHTML variable, effectively repeating the HTML code 9 times within that element.
原文地址: https://www.cveoy.top/t/topic/p3KK 著作权归作者所有。请勿转载和采集!