e.preventdefault()不与Mousedown事件合作?

发布于 2025-01-22 20:46:02 字数 699 浏览 3 评论 0原文

我已经写了以下代码,以防止点击事件。它按照以下代码的预期工作。

$(".k-grid-filter").on('mousedown', function (e) {
    var editRow = $(this).closest(".k-grid").find(".k-grid-edit-row");
    if (editRow.length > 0) {
        e.preventDefault();
        e.stopImmediatePropagation();
        alert(e.type);
    }
});

但是我不想显示警报弹出窗口。如果我删除Alert(),则Destrest -Deffault()不起作用。

$(".k-grid-filter").on('mousedown', function (e) {
        var editRow = $(this).closest(".k-grid").find(".k-grid-edit-row");
        if (editRow.length > 0) {
            e.preventDefault();
            e.stopImmediatePropagation();
        }
    });

有人可以帮助我找到缺少的东西吗?要做什么才是工作? 提前致谢 :)

I have written below code to prevent click event. Its working as expected with below code.

$(".k-grid-filter").on('mousedown', function (e) {
    var editRow = $(this).closest(".k-grid").find(".k-grid-edit-row");
    if (editRow.length > 0) {
        e.preventDefault();
        e.stopImmediatePropagation();
        alert(e.type);
    }
});

But I don't want to display alert pop-up. If I remove alert(), preventDefault() is not working.

$(".k-grid-filter").on('mousedown', function (e) {
        var editRow = $(this).closest(".k-grid").find(".k-grid-edit-row");
        if (editRow.length > 0) {
            e.preventDefault();
            e.stopImmediatePropagation();
        }
    });

Can anybody please help me to find is missing and what has to be done to make is work?
Thanks in advance :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

游魂 2025-01-29 20:46:02

MouseUpMousedown都不要阻止默认单击事件。

请参阅此答案有关更多详细信息。

Neither of mouseup or mousedown prevent the default click event.

See this answer for more details.

醉梦枕江山 2025-01-29 20:46:02

您不能使用e.preventDefault() in mousedownmouseup事件,因为该函数仅在上工作>单击 您必须选择该部分。

当指针在元素内部时按下指向设备按钮时,mousedown事件是在元素上发射的。

您可以检查此链接的参考20 fired%20AT%20AT%20AN%20 elemt%20A%20A%20点%20DEVICE%20Button%20IS%​​20%20 while%20 the%20 pointer%20IS%​​20IS%​​20InSIDE%20%20%20%emplement。” rel =“ nofollow noreferrer”>在这里

You can't use e.preventDefault() in mousedown and mouseup event because the function only works on click you have to select that part.

The mousedown event is fired at an Element when a pointing device button is pressed while the pointer is inside the element.

you can check reference of this link here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文