如何在悬停时暂停Bootstrap Carousel,并在鼠标移开时恢复它? [英] How can I pause a Bootstrap Carousel on hover and resume it on mouse-out?
本文介绍了如何在悬停时暂停Bootstrap Carousel,并在鼠标移开时恢复它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网站上有一个Bootstrap Carousel。
I have a Bootstrap Carousel on my website.
当用户将鼠标悬停在元素 #formcontainer
上时,我想暂停轮播。当我悬停时,我想继续轮播的循环。第一部分在下面的代码中工作正常,但第二部分却没有。有人可以协助吗?
When the user hovers over an element #formcontainer
, I'd like to pause the carousel. And when I hover off, I'd like to continue the cycle of the carousel. The first part works fine with the following code, but not the second. Can someone assist?
$(document).ready(function() {
$('.carousel').carousel({
interval: 1200,
pause: "hover"
});
$('#formcontainer').hover(function(){
$("#myCarousel4").carousel('pause');
});
});
推荐答案
使用轮播 cycle
方法在 mouseleave
事件
$('#formcontainer').hover(function(){
$("#myCarousel4").carousel('pause');
},function(){
$("#myCarousel4").carousel('cycle');
});
这篇关于如何在悬停时暂停Bootstrap Carousel,并在鼠标移开时恢复它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文