从单击链接/按钮到触发事件,我已经读到了 mobile Safari has a 300ms delay on click events.延迟的原因是等待看看用户是否打算双击,但从用户体验的Angular 来看,等待300ms通常是不可取的.
One solution to eliminate this 300ms delay is to use jQuery Mobile "tap" handling. Unfortunately I'm not familiar with this framework and don't want to load some big framework if all I need is a line or two of code applying touchend
in the right way.
像许多网站一样,我的网站有很多这样的点击事件:
$("button.submitBtn").on('click', function (e) {
$.ajaxSubmit({... //ajax form submisssion
});
$("a.ajax").on('click', function (e) {
$.ajax({... //ajax page loading
});
$("button.modal").on('click', function (e) {
//show/hide modal dialog
});
我想做的是用一段代码消除ALL个点击事件的300毫秒延迟,如下所示:
$("a, button").on('tap', function (e) {
$(this).trigger('click');
e.preventDefault();
});
这是个坏主意/好主意吗?