简体   繁体   English

如何检测用户的手指何时离开元素?

[英]How to detect when user's finger away the element?

Now user taps the image, moves the finger away, release finger and can see the alert. 现在,用户点击图像,将手指移开,松开手指即可看到警报。 Is it possible to check where user release finger and if he still on original image to show him alert? 是否可以检查用户在哪里释放手指以及他是否仍在原始图像上以显示警报? Otherwise do nothing. 否则什么都不做。

Try this: 尝试这个:

var touchedObject;

$('body').bind("touchstart", function(e){
    touchedObject = $(this);
});

$('body').bind("touchend", function(e){
    if (touchedObject == $(this)) {
        //show alert
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM