【发布时间】:2016-02-16 00:50:39
【问题描述】:
我有一个 html 代码块
<div class="modal-comment-content">
<ul class="list-inline">
<li><a href="#"><img src="/defaultpic.jpg" width="100" class="img-circle"></a></li>
<li>
<ul class="list-unstyled">
<li><a href="#" class="comment_username">John D.</a></li>
<li class="comment_created_at">~ 4 hours ago</li>
</ul>
</li>
</ul>
<p class="comment_comment">This is a completely random sentence. This is the second sentence. Closing sentence right here.</p>
<hr>
</div>
我有一个迭代对象数组的 for 循环。
for (var i = 0; i < json.length; i++)
{
var user = json[i].user.first_name + ' ' + json[i].user.last_name.charAt(0) + '.';
var comment = json[i].comment;
var created_at = json[i].created_at;
}
我想将 html 代码块用作数组对象每次迭代的“模板”。关于如何完成的任何想法?问候,
【问题讨论】:
标签: javascript jquery html json for-loop