jQuery each function html list, just return object
I have a bit of problem with my function who just should return html code
function contentStringHtml(data, name) {
return '<div id="gm-event-title">' +
'<h2>' + name + '</h2>' +
'</div>' +
'<div class=\"gm-trafic-index\"&开发者_如何学Pythongt;<ul>' +
$.each(data.DataTime, function(i, item) {
return '<li class=\"gm-trafic-li"\>' + item.TimeAndTo + '</li>';
});
+ '</ul></div>';
}
the don't return the {0} in the each loop.
function contentStringHtml(data, name) {
var list;
$.each(data.DataTime, function(i, item) {
list += '<li class="gm-trafic-li">' + item.TimeAndTo + '</li>';
});
return '<div id="gm-event-title"><h2>'+name+'</h2></div>' +
'<div class="gm-trafic-index">' +
'<ul>'+list+'</ul></div>';
}
精彩评论