问题是,我有4个功能,我想每隔5秒左右顺序运行一次,我不知道该如何去做
我知道代码效率低下.(现在我已经设置了这种方式,所以也可以通过点击按钮触发功能)
function tScroll1(){
var $testimonialScrollPos = parseInt($tCont.css('top'), 10);
if($testimonialScrollPos == -915){
$tCont.css('top','305px');
$tCont.animate({top:'0px'},700);
}
else{
$tCont.animate({top:'0px'},700);
}
};
function tScroll2(){
$tCont.animate({top:'-305px'},700);
};
function tScroll3(){
$tCont.animate({top:'-610px'},700);
};
function tScroll4(){
$tCont.animate({top:'-915px'},700);
};
$tBtns.eq(0).click(function(){tScroll1()});
$tBtns.eq(1).click(function(){tScroll2()});
$tBtns.eq(2).click(function(){tScroll3()});
$tBtns.eq(3).click(function(){tScroll4()});
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏 :].
我有4个函数在setInterval(tscrolls)上运行,只要加载文档,它就会每隔几秒为div的顶部位置设置动画.
var intervalFunctions = [ tScroll1, tScroll2, tScroll3, tScroll4 ];
var intervalTimer = 3000;
window.setInterval(function(){
intervalFunctions[intervalIndex++ % intervalFunctions.length]();
}, intervalTimer);
Run Code Online (Sandbox Code Playgroud)
有没有办法暂停鼠标中心或悬停?