iPhone jQuery点击事件 [英] iPhone jQuery click event
本文介绍了iPhone jQuery点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的点击事件附加在我的网络应用程序上的一些锚点。
I have a simple click event attached to a number of anchors on my web app.
$('a.heading').live("click", function(e) {
e.preventDefault();
//do my stuff
});
这不是火箭科学。然而在我的iPhone上,点击不注册。它会出现它使用iPhone的触摸处理程序(iPad,Android等都是很好的)。
It's not rocket science. However on my iPhone the click doesn't register. It would appear it uses the touch handler for iPhone (iPad, Android etc are all fine).
我看过一些教程,但似乎不能得到我的头周围。有没有一个班轮,我可以使用jQuery是这样通常是好的?
I've seen a couple of tutorials but cannot seem to get my head around it. Is there not a one liner that I can use that jQuery is so usually good at?
推荐答案
p>
This did the trick:
var userAgent = navigator.userAgent.toLowerCase();
var isiPhone = (userAgent.indexOf('iphone') != -1 || userAgent.indexOf('ipod') != -1) ? true : false;
clickEvent = isiPhone ? 'tap' : 'click';
这篇关于iPhone jQuery点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文