您好
我想把"追加"在我之前(for)和之后" append_after"
****
append = '<div class="row"><div class="col-md-12 col-lg-12" ><div class="carousel slide media-carousel" data-interval="false" id="media"><div class="carousel-inner" ><div class="item active"><div class="row">';
var newHTML = [];
var counter = 16;
for (var i = 0; i < results.length; i++) {
output = '';
if (i % counter === 0) {
output += '</div>';
output += '</div>';
output += '<div class="item">';
output += '<div class="row">';
}
output += '<div class="col-md-2">';
output += '<img src="' + results[i].Name + '.png" />';
output += '</div>';
newHTML.push(output);
}
$("#update").html(newHTML);
append_after = '</div></div></div></div></div></div></div>';
****
你知道我怎么做吗?
ps:我的代码还没有完整。
THX
答案 0 :(得分:1)
只需push
newHTML
数组,就像使用output
变量一样:
append = '<div class="row"><div class="col-md-12 col-lg-12" ><div class="carousel slide media-carousel" data-interval="false" id="media"><div class="carousel-inner" ><div class="item active"><div class="row">';
var newHTML = [];
var counter = 16;
newHTML.push(append)
for (var i = 0; i < results.length; i++) {
...
...
}
append_after = '</div></div></div></div></div></div></div>';
newHTML.push(append_after)