I have $each loop in jquery as below
some code---------
var temp="";
var msg_html="";
$.each(_d, function(index, val) {
var currentID=val.id;
if(temp.match(new RegExp("(?:^|,)"+currentID+"(?:,|$)"))) {
msg_html+'_'+currentID += messageTemplate(val.photo, val.from_name, val.message);
} else{
msg_html+'_'+currentID += messageTemplate(val.photo, val.from_name, val.message);
temp += currentID + ",";
}
});
some code ------------------
If the above code works, I can display as like,
$('#someID_0').html(msg_html_0);
$('#someID_1').html(msg_html_1);
$('#someID_2').html(msg_html_2);
----
---
---
The problem in this code is that some error in "msg_html+'_'+currentID "as invalid assignment. Any other way to assign dynamically?
$('#someID_' + currentId).html(/** html here **/)inside the loop instead?$('#someID_' + currentId).append(messageTemplate(val.photo, val.from_name, val.message))inside the.each()loop?