e.preventdefault()不与Mousedown事件合作?
我已经写了以下代码,以防止点击事件。它按照以下代码的预期工作。
$(".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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MouseUp
或Mousedown
都不要阻止默认单击事件。请参阅此答案有关更多详细信息。
Neither of
mouseup
ormousedown
prevent the default click event.See this answer for more details.
您不能使用
e.preventDefault()
inmousedown
和mouseup
事件,因为该函数仅在上工作>单击
您必须选择该部分。当指针在元素内部时按下指向设备按钮时,
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()
inmousedown
andmouseup
event because the function only works onclick
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