クリック イベントが iOS で機能しない場合は、touchstart、touchmove、および touchend イベントを使用して、ユーザーが画面をタップしたかどうかを判断します。
以下の JavaScript:
var tap = true;
document.addEventListener('touchstart',function(e) {
tap = true;
});
document.addEventListener('touchmove',function(e) {
tap = false;
});
document.addEventListener('touchend',function(e) {
if(tap) {
//users tapped the screen
}
});
ユーザー座標については、changedTouches オブジェクトを使用して、ユーザーがページのどこをタップしたかを確認します。
JavaScript:
var tap = true;
document.addEventListener('touchstart',function(e) {
tap = true;
});
document.addEventListener('touchmove',function(e) {
tap = false;
});
document.addEventListener('touchend',function(e) {
if(tap) {
var touch = e.changedTouches[0];
var pageX = touch.pageX;
var pageY = touch.pageY;
}
});
それが役立つことを願っています