javascript - Getting current DOM object that touchmove or touchend is over - Stack Overflow

As Mozilla states on the TouchEvent page:The event's target is the same elementthat received the

As Mozilla states on the TouchEvent page:

The event's target is the same element that received the touchstart event corresponding to the touch point, even if the touch point has moved outside that element.

This is not the same as mousemove and mouseup, where the target really is the DOM element that the mouse is over.

What's the best way, without using any library, to get the element that my touchmove or touchend event occurs on?

As Mozilla states on the TouchEvent page:

The event's target is the same element that received the touchstart event corresponding to the touch point, even if the touch point has moved outside that element.

This is not the same as mousemove and mouseup, where the target really is the DOM element that the mouse is over.

What's the best way, without using any library, to get the element that my touchmove or touchend event occurs on?

Share Improve this question edited Jul 25, 2022 at 17:55 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked May 8, 2012 at 21:02 Simon SarrisSimon Sarris 63.9k13 gold badges149 silver badges174 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Read the coordinates (pageX and pageY) from the event object. Then use document.elementFromPoint(x, y) to get the top element at that position.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742386942a4434248.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信