我需要jquery切片来显示单击div列表的下一个5个div如何在点击时增加切片变量的长度?
var $p1 = 0;
var $p2 = 5;
var $increaseslice = (function () {
$p1 + 5;
$p2 + 5;
});
var $divselector = $('.date-sheet > .date-sheet-row');
console.log($p1 + $p2);
// Stuff to do as soon as the DOM is ready;
$($divselector).slice($p1, $p2).css('display', 'block');
$('#next').on('click', function () {
console.log();
$($divselector).slice($p1, $p2).hide('slow');
$increaseslice();
console.log($p1 + $p2);
$($divselector).slice($p1, $p2).show('slow');
});
这是我现在拥有的,但它每次只循环相同的5个div ... fiddle
答案 0 :(得分:1)
使用+ =向其中添加5
$p1 += 5; // same as $p1 = $p1 + 5
$p2 += 5; // same as $p2 = $p2 + 5