我有一个图像滑块,每5秒更换一次图像,但我希望滑块在我停留在div img时暂停。有没有办法在悬停时暂停'theRotator'函数,然后在鼠标移出div后重新启动它?谢谢大家!元素悬停时暂停功能
function theRotator() {
//Set the opacity of all images to 0
$('div.rotator ul li').css({opacity: 0.0});
//Get the first image and display it (gets set to full opacity)
$('div.rotator ul li:first').css({opacity: 1.0});
//Call the rotator function to run the slideshow,
setInterval('rotate()',5000);
}
$(document).ready(function() {
//Load the slideshow
theRotator();
$('div.rotator').fadeIn(1000);
$('div.rotator ul li').fadeIn(1000); // tweek for IE
});
出于某种原因,我认为你跑了两次,为什么? 我觉得你应该这样做,运行.delay() - >在jquery.com上阅读它。 – IamStalker 2012-02-11 22:31:03