<script type="text/javascript">
$(function(){
var sx=0;
var timer=null;
//底部按钮切换
$('.all ol li').hover(function(event) {
var index= $(this).index();
$(this).addClass('current').siblings().removeClass();
$('.all ul').stop().animate({
left:index*-400
}, 500);
sx=index;
});
//左右箭头切换
$('.all .left').click(function(event) {
sx--;
if (sx<0) {
sx=5;
}
$('.all ol li').eq(sx).addClass('current').siblings().removeClass();
$('.all ul').stop().animate({
left:sx*-400
}, 500);
});
$('.all .right').click(function(event) {
sx++;
if (sx>5) {
sx=0;
}
$('.all ol li').eq(sx).addClass('current').siblings().removeClass();
$('.all ul').stop().animate({
left:sx*-400
}, 500);
});
//自动滚动
timer = setInterval(autoplay,2000);
function autoplay(){
sx++;
if (sx>5) {
sx=0;
}
$('.all ol li').eq(sx).addClass('current').siblings().removeClass();
$('.all ul').stop().animate({
left:sx*-400
}, 500);
$('.all').hover(function() {
clearInterval(timer);
}, function() {
clearInterval(timer);
timer=setInterval(autoplay,2000);
});
}
})
</script>
$(function(){
var sx=0;
var timer=null;
//底部按钮切换
$('.all ol li').hover(function(event) {
var index= $(this).index();
$(this).addClass('current').siblings().removeClass();
$('.all ul').stop().animate({
left:index*-400
}, 500);
sx=index;
});
//左右箭头切换
$('.all .left').click(function(event) {
sx--;
if (sx<0) {
sx=5;
}
$('.all ol li').eq(sx).addClass('current').siblings().removeClass();
$('.all ul').stop().animate({
left:sx*-400
}, 500);
});
$('.all .right').click(function(event) {
sx++;
if (sx>5) {
sx=0;
}
$('.all ol li').eq(sx).addClass('current').siblings().removeClass();
$('.all ul').stop().animate({
left:sx*-400
}, 500);
});
//自动滚动
timer = setInterval(autoplay,2000);
function autoplay(){
sx++;
if (sx>5) {
sx=0;
}
$('.all ol li').eq(sx).addClass('current').siblings().removeClass();
$('.all ul').stop().animate({
left:sx*-400
}, 500);
$('.all').hover(function() {
clearInterval(timer);
}, function() {
clearInterval(timer);
timer=setInterval(autoplay,2000);
});
}
})
</script>