简体   繁体   English

从mousedown事件停止点击动作

[英]stop click action from mousedown event

Im building an application which is intended for speed, and Im thinking to process actual page loads on mousedown event than click event, so the gap between the mousedown and click saves me some milliseconds(about 100ms), my app can load pages with in that 100ms time, so it just runs instant. 我正在构建一个旨在提高速度的应用程序,并且我考虑在mousedown事件而不是click事件上处理实际的页面加载,因此mousedown和click之间的间隔节省了几毫秒(约100毫秒),我的应用程序可以在其中加载页面100ms时间,因此它可以立即运行。

 $(document).on('mousedown','a.magic_links',function(e) {
             $(this).click().off("click");

            });

I tried this code, but not preventing the default click action, any suggestions to achieve this? 我尝试了这段代码,但没有阻止默认的点击操作,有什么建议可以实现?

You want to prevent the default behavior of the event (or cancel it). 您想要阻止事件的默认行为(或取消它)。

What you are currently trying to do is remove an event handler that was never created in the first place 您当前要执行的操作是删除从未创建过的事件处理程序

$(document).on('mousedown','a.magic_links',function(e) {
     e.preventDefault();
     // code here to do your loading

});

Personally I think you should rethink this over-optimization strategy as it may not be optimal for all devices 我个人认为您应该重新考虑这种过度优化策略,因为它可能不适用于所有设备

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM