我有jQuery代码:
setInterval(function() {
var grayarrow = jQuery("ul#dropdowngray").parent();
var greenarrow = jQuery("ul#dropdown").parent();
grayarrow.effect('shake', { times:2 }, 100);
greenarrow.effect('shake', { times:3 }, 200);
jQuery("ul#dropdowngray").parent().hover(
function (){ grayarrow.stop().effect('shake', { times:0 }, 100); },
function (){ grayarrow.stop().effect('shake', { times:2 }, 100); }
);
jQuery("ul#dropdown").parent().hover(
function (){ greenarrow.stop().effect('shake', { times:0 }, 100); },
function (){ greenarrow.stop().effect('shake', { times:2 }, 100); }
);
}, 5000);
但是,当我将鼠标悬停在元素上时,震动会继续执行。最初,我有代码:
jQuery("ul#dropdowngray").parent().hover(
function (){ grayarrow.stop(); },
function (){ grayarrow.stop(); }
);
但是,由于这也不起作用,我实现了这里讨论的解决方案:jquery .stop() not working
当鼠标悬停在摇晃元素上时,如何有效地停止摇晃?
谢谢,