最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get the element under a touchend - Stack Overflow

programmeradmin5浏览0评论

As the touchend event is bind to the element where the touchstart is fired, how can I get the element at the position where the finger leaves, when this is outside of the element where the event was binded to.

As the touchend event is bind to the element where the touchstart is fired, how can I get the element at the position where the finger leaves, when this is outside of the element where the event was binded to.

Share Improve this question edited Sep 26, 2012 at 6:55 niksvp 5,5632 gold badges27 silver badges43 bronze badges asked Sep 26, 2012 at 6:52 Andreas KöberleAndreas Köberle 111k58 gold badges280 silver badges307 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 20

You could use the document.elementFromPoint method, passing it the coordinates of the event:

$('#element').on("touchend",function(event){
    var endTarget = document.elementFromPoint(
        event.originalEvent.touches[0].pageX,
        event.originalEvent.touches[0].pageY
    );
});

EDIT: Found some good article about getting elements at specific coordinates. http://www.zehnet.de/2010/11/19/document-elementfrompoint-a-jquery-solution/

发布评论

评论列表(0)

  1. 暂无评论