我正在使用无限循环功能,该功能根据我的需要进行了一些修改:
$(document).ready(function() {
var NewsRotator = {init: function()
{
var numberOfTitles = $('.NewsRotator li').length;
//set current item
var currentTitle = 0;
//show first item
$('.NewsRotator li').eq(currentTitle).fadeIn(1000); //initial fade-in
//loop through the items
var infiniteLoop = setInterval(function(){
$('.NewsRotator li').eq(currentTitle).fadeOut(100); //current item fade-out time
if(currentTitle == numberOfTitles -1){
currentTitle = 0;
}else{
currentTitle++;
}
$('.NewsRotator li').eq(currentTitle).fadeIn(900); //next item fade-in time
}, 3000); //interval between items
}
};
NewsRotator.init();
});
这是jsFiddle上的工作示例
我想要做的是在鼠标悬停时设置动画暂停并在鼠标离开时恢复它。
谢谢!