<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script>
$(document).ready(function(){
// debugger;
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
//循环样式结构
function fun(arr, index) {
// debugger;
var str = "";
str += '<div >';
for (var i = (index - 1) * 5; i < (index - 1) * 5 + 5; i++) {
if (arr[i] != undefined) {
str += '<div >' + arr[i] + '</div>';
}
}
str += "</div>";
$("#myresult").html("");
$("#myresult").append(str);
}
var mytime = setInterval(function () { showme() }, 2000);
var arrk = 1;
function showme()
{
fun(array, arrk);
arrk += 1;
//debugger;
if (arrk == Math.ceil(array.length / 5)+1)
{
arrk = 1;
// clearInterval(mytime);
}
}
});
</script>
</head>
<body>
<div id="myresult" style=" width:300px;height:200px"></div>
</body>
</html>
原文地址:https://www.cnblogs.com/TTonly/p/10674717.html
时间: 2024-11-10 12:18:20