Skip to content Skip to sidebar Skip to footer

Find Element Finger Is On During A Touchend Event

I need to discover which html element was under the finger when the touchend event is called. The code I am using; $('.wsSquare').on('mouseup touchend',function(event){ event.p

Solution 1:

Use document.elementFromPoint and feed it the co-ordinates from the events, for example, like this:

$('.wsSquare').on("mouseup touchend",function(event){
    event.preventDefault();
    event.stopPropagation();
    var changedTouch = event.changedTouches[0];
    var elem = document.elementFromPoint(changedTouch.clientX, changedTouch.clientY);
    // Do something with elem
});

Post a Comment for "Find Element Finger Is On During A Touchend Event"