function randomBox(randomItem) {
randomItem = $(randomItem);
var random = Math.floor(Math.random() * randomItem.length);
randomItem.eq(random % randomItem.length).addClass('active');
function startRand() {
var current = randomItem.parent().find('.active');
if ( current.is(':last-child') ) {
current.removeClass('active');
current.siblings(':first-child').addClass('active');
} else {
current.removeClass('active');
current.next().addClass('active');
}
setTimeout(function(){startRand()}, 2500);
}
startRand();
}
randomBox('.list > .item');
Leave a Reply