如何使用Safari中的jQuery识别触摸事件?可能吗? [英] How to recognize touch events using jQuery in Safari for iPad? Is it possible?

查看:106
本文介绍了如何使用Safari中的jQuery识别触摸事件?可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用jQuery在iPad的Safari浏览器上识别触摸事件吗?

Is it possible to recognize touch events on the iPad's Safari browser using jQuery?

我在web应用程序中使用了mouseOver和mouseOut事件。有没有类似的事件为iPad的Safari浏览器,因为没有像mouseOut,mouseMove这样的事件?

I used mouseOver and mouseOut events in a web application. Are there any similar events for the iPad's Safari browser since there are no events like mouseOut, mouseMove?

推荐答案

核心jQuery不对于触摸事件有什么特别之处,但您可以使用以下事件轻松构建自己的

Core jQuery doesn't have anything special for touch events, but you can easily build your own using the following events


  • touchstart

  • touchmove

  • touchend

  • touchcancel

  • touchstart
  • touchmove
  • touchend
  • touchcancel

例如, touchmove

document.addEventListener('touchmove', function(e) {
    e.preventDefault();
    var touch = e.touches[0];
    alert(touch.pageX + " - " + touch.pageY);
}, false);

这适用于大多数基于webkit的浏览器(包括android)。

This works in most webkit based browsers (incl. android).

这里有一些良好的文件:

这篇关于如何使用Safari中的jQuery识别触摸事件?可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆