Difference between jquery.clone() and simple concatenation of string [closed]
- by Francis Cebu
Which of the following code samples is faster in generating HTML code using jQuery?
Sample 1:
var div = $("<div>");
$.each(data,function(count,item){
var Elem = div.clone().addClass("message").html(item.Firstname);
$(".container").append(Elem);
});
Sample 2:
$.each(data,function(count,item){
var Elem = "<div class = 'Elem'>" + item.Firstname + "</div>";
$(".container").append(Elem);
});