我从 ajax 调用中请求了一些 json 数据,并将所有数据插入到表中。现在就像下面的代码一样,所有数据都在一行单元格中,有没有办法循环遍历表格并将其拆分为多行,每行包含 4 个单元格?
<div id="gallery">
<table id="galleryTable"><tr></tr></table>
</div>
$.ajax({
type: "GET",
dataType: "jsonp",
cache: false,
url: linkurl,
success: function(data){
paginate = data.pagination.next_url;
var nextMaxId = data.pagination.next_max_id;
console.log(nextMaxId);
for(var i=0; i<15; i++){
var instaPics = data.data[i].images.low_resolution.url;
var avatar = data.data[i].user.profile_picture;
var like = data.data[i].likes.count;
var comment = data.data[i].comments.count;
console.log(comment);
$(#galleryTable tr').append('<td><img class="tagPics" src="'+instaPics+'"><a>'+like+"likes"
+'</a><img class="avatar" src="'+avatar+'" height="20" width="20" /><a>'+comment+'</a></img></td>');
};
}
});