您好,我在網站上的JS客戶端滑塊有問題。鼠標懸停/鼠標左鍵的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()'試試' – vijayP
謝謝你的回答,但它仍然不起作用 –
你可以在這裏創建一個小提琴或工作片段嗎? – vijayP