我尝试每天显示一个列表项,当列表到达末尾时,我希望它转到开头,这就是我正在使用的javascript。
// Get the number of the week since the epoch.
var day = Math.floor(new Date().getTime() / (1000 * 60 * 60 * 24 * 7 * 1));
i = 0;
// Show one div per day.
$('#postTips li').hide();
$('#postTips li ') + (i = ++i % day)).show();发布于 2016-03-23 10:41:39
如果您希望一天显示一个列表项,第二天显示下一个列表项:
var day = 0, list_items = $('#postTips li'), current_list_item = 0, total_list_item = list_items.length;
function update_list_item() {
var day_new = Math.floor(new Date().getTime() / (1000 * 60 * 60 * 24 * 1));
if (day_new > day) {
day = day_new;
list_items[current_list_item].style.display='none';
list_items[current_list_item=day%total_list_item].style.display='list-item';
}
requestAnimationFrame (update_list_item);
}
list_items.hide ();
update_list_item ();https://stackoverflow.com/questions/36168736
复制相似问题