jquery - 如何为这个 jquery 函数添加一个暂停?

标签 jquery html css

我一直在想办法让这个函数在鼠标悬停时暂停,并在鼠标移出时继续。我已经想出如何在鼠标悬停时暂停该功能,但它不会在鼠标移出时再次启动。这是 jQuery 代码(从另一个教程中使用)。

function swapImages(){  
 var $active = $('#myGallery .active');    
var $next = ($('#myGallery .active').next().length > 0) ? $('#myGallery .active').next() : $('#myGallery img:first');  
 $active.fadeOut(function(){     
$active.removeClass('active');      
$next.fadeIn().addClass('active'); }); }  

 $(document).ready(function(){setInterval('swapImages()', 5000);}  
 $('#myGallery').mouseover(function(){ 
 $(this).delay(60000);
});

最佳答案

使用 jQuery 的 hover

$( selector ).hover( handlerIn, handlerOut )

简称

$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );

关于jquery - 如何为这个 jquery 函数添加一个暂停?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22079509/

相关文章:

javascript - 当select有值时在select by text中选择值?

html - 如何将文本向上和向右移动一点?

html - Outlook Windows 上电子邮件的字体系列不适用

javascript - 带 Owl Carousel 的 slider

php - 在布局中创建新行的功能无法正常工作

Javascript 函数在 google chrome 中不起作用

javascript - 当 CSS3 列溢出时重复 HTML 标题

jquery - 焦点在 iframe 之外

javascript - 可选上传字段 javascript

javascript - 将文本区域符号限制为可见部分