JS实现数组每次只显示5条数据
var array = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
//循环样式结构
function fun(arr,index){
var str = "";
str += '<div class="img_group">';
for(var i=(index-1)*5;i<(index-1)*5+5;i++){
if(arr[i]!=undefined){
str += '<div class="imgDiv">'+arr[i]+'</div>';
}
}
str += "</div>";
$(".img_list").append(str);
}
for(var nums = 0;nums<Math.ceil(array.length / 5);nums++){
fun(array,num);
num++;
}