I have a var that I want to append multiple times with jQuery. The code is like so:
var number = 4; //number of times the html must be appended
html = $("<div>Content here</div>"); //The html I want to append
$(document).ready(function() {
$("body").append(html * number); //Append the div multiple times
});
I’m wondering how I can make the html var append the amount of times mentioned in the number var (4)? The code above doesn’t work, and I can see why. But I can’t see a way to fix it. Any ideas? (I’m not a great expert at jQuery!)
you can do it like this remove
$alsoworking demo