【发布时间】:2016-08-26 09:43:57
【问题描述】:
您好,网站上的 JS 客户端滑块有问题。
我想在 mouseover 时停止它并在 mouseleft 时继续。我已经搜索并检查了代码,但我不知道为什么它仍然不起作用,有人可以帮助我吗?
$(function(){
var $clientcarousel = $('#clients-list');
var clients = $clientcarousel.children().length;
var clientwidth = (clients * 400); // 140px width for each client item
$clientcarousel.css('width',clientwidth);
var rotating = true;
var clientspeed = 0;
var seeclients = setInterval(rotateClients, clientspeed);
function rotateClients() {
if(rotating != false) {
var $first = $('#clients-list li:first');
$first.animate({ 'margin-left': '-220px' }, 5000, "linear", function() {
$first.remove().css({ 'margin-left': '0px' });
$('#clients-list li:last').after($first);
});
}
}
});
$(document).on({
mouseover: function(){
rotating = false; // turn off rotation when hovering
},
mouseleave: function(){
rotating = true;
}
}, '#clients');
【问题讨论】:
-
你能用
mouseenter: function()代替mouseover: function()试试 -
感谢您的回答,但它仍然不起作用
-
你能在这里创建一个小提琴或工作 sn-p 吗?
标签: javascript jquery slider mouseevent mouseover