1
ALeo 2015-04-09 14:51:01 +08:00 1
data.list.each
|
2
tension OP @ALeo
我现在写的 $.each(value.result.list,function(i,n){ html +='<dd>'; html +='<span id="opt1">'+datetime+'</span><span id="opt2">'+remark+'</span>'; html +='</dd>'; }); 不对么? |
3
ALeo 2015-04-09 15:03:00 +08:00 1
@tension 肯定不对。。
$.each(value.result.list,function(val){ html +='<dd>'; html +='<span id="opt1">'+val.datetime+'</span><span id="opt2">'+val.remark+'</span>'; html +='</dd>'; }); |
5
subpo 2015-04-09 15:17:57 +08:00 1
list.forEach(function(item){
console.log(item) }) |
7
tension OP var info = data.result.list;
var html = ""; $.each(info,function(val){ html +='<dd>'; html +='<span class="extime">'+val.datetime+'</span><span class="exremark">'+val.remark+'</span>'; html +='</dd>'; }); |
8
tension OP @ALeo
var info = data.result.list; var html = ""; $.each(info,function(n,val){ html +='<dd>'; html +='<span class="extime">'+val.datetime+'</span><span class="exremark">'+val.remark+'</span>'; html +='</dd>'; }); 搞定 |
9
xmbaozi 2015-04-09 16:16:43 +08:00
var tpl = '<span class="extime">{datetime}</span><span class="exremark">{remark}</span>';
function render(obj) { return tpl.replace(/\{(\w+)\}/g, function ($0, $1) { return obj[$1]; }); } var html = render(valObj); 我喜欢用模板 看起来优雅点点 :D |