Get the element under a touchend

前端 未结 1 1239
谎友^
谎友^ 2021-01-17 12:20

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

相关标签:
1条回答
  • 2021-01-17 13:14

    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 讨论(0)
提交回复
热议问题