jQuery mobile-对于每个实时点击事件,应该有一个等效的click事件吗?

问题描述:

我已将jQuery实时点击事件替换为jQuery移动点击事件,以提高响应速度.

I have replaced the jQuery live click events to jQuery mobile tap events to increase responsiveness.

出于兼容性原因,我觉得这是个坏主意.

I have a feeling this was a bad idea for compatibility reasons.

是否必须同时具有两个事件,并且有什么方法可以将两个事件都写入同一功能?

Is it necessary to have both events, and is there any way to write them both for the same function?

例如('click','tap')

Such as ('click','tap')

Billy的答案非常完整,在我使用几次后实际上效果很好.但是,此外,您可能希望查看 JQuery Mobile 中的vmouse插件,这是一种尝试提取鼠标事件:

Billy's answer is incredibly complete and actually worked quite well the few times I used it. Additionally however, you may want to look at the vmouse plugin in JQuery Mobile, it is an attempt to abstract mouse events:

 // This plugin is an experiment for abstracting away the touch and mouse
 // events so that developers don't have to worry about which method of input
 // the device their document is loaded on supports.

- https://github.com/jquery /jquery-mobile/blob/master/js/vmouse.js

我一直在我正在从事的项目中使用它,这些天似乎反应很快.要使用,类似于:

I've been playing with it on a project I'm working on, it seems pretty responsive these days. To use, something like:

$('selector').bind('vclick', function () { ...

$('selector').bind('vmousedown', function () { ...