首页 > 解决方案 > 事件是火,如果我添加类

问题描述

如果我添加类...

$(".cart").addClass("show_cart");

...它触发 mouseenter 而不是 mouseleave 事件

$(document).on({
        mouseenter: function () {
            ....
        },
        mouseleave: function () {
            ....
        }
    }, '.show_cart');

我究竟做错了什么?为什么会触发事件?只有当我将鼠标移到元素上时,我才想触发事件 mouseenter。

标签: jqueryeventsmouseenter

解决方案


推荐阅读