首页 文章

在mouseleave jquery上停止函数

提问于
浏览
1

我正在尝试使用mouseenter和mouseleave来启动和停止颜色动画功能,但它不会在mouseleave上停止...请帮我弄清楚:

答:如果mouseenter / leave是要调用的正确事件(或者我应该使用鼠标悬停还是悬停?)

B:使用.stop结束函数的正确结构

<script>
    $(document).ready(function() {
        $("#logo").bind('mouseenter', function() {
            pixelColors() });

        $("#logo").bind('mouseleave', function() {
            pixelColors().stop(true, true); });
    });
</script>

1 回答

  • 1

    Interstellar_Coder说得对;你需要在jquery对象上调用stop;尝试用jQuery(this)替换回调函数中的pixelColors,即jQuery(this).stop(true,true);

相关问题