I am generating a dom element <div> using the code below:
jQuery
$('<div/>', {
'id': 'myid',
'html': '<table class="table">'
+ '<tr><th>Heading</th><th>Heading</th><th>Heading</th></tr>'
+'</table>'
}).appendTo($body);
Everything works great. I would like to loop through my data to create the actual table rows, but I'm getting actual output (which makes sense I suppose). Just not sure how to not do that.
For example:
jQuery
$('<div/>', {
'id': 'myid',
'html': '<table class="table">'
+ '<tr><th>Heading</th><th>Heading</th><th>Heading</th></tr>' +
$.each(data.thing, function(i, val){
'<tr><td> </td><td> </td><td> </td></tr>
});
+'</table>'
}).appendTo($body);
But, I am getting this for the result:
HTML
[object Object],[object Object],[object Object],[object Object],[object Object],[object
Object],[object Object],[object Object]
Heading Heading Heading