jQuery的轮播图
$(function () {
var sliderContent = $('.slider-content');
var imgWith = $('.slider-item').outerWidth();
var index = 1;
var size = $('.slider-item').length - 2;
var t = setInterval(function () {
index++;
move(index);
}, 1000);
$('#banner-slider').hover(function () {
clearInterval(t);
}, function () {
t = setInterval(function(){
index++;
move(index);
}, 1000);
});
$('.btn-next').on('click', function () {
index++;
move(index);
});
$('.btn-pre').on('click', function () {
index--;
move(index);
})
function move() {
if (index == (size + 1)) {
sliderContent.stop().css({
left: 0
});
index = 1;
}
if (index == 0) {
sliderContent.stop().css({
left: -3300
});
index = 5;
}
sliderContent.stop().animate({
left: -index * 550
}, 500);
$('.pagination').eq(index - 1).addClass('active').siblings().removeClass('active');
}
});