admin管理员组文章数量:1336633
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?
1 Answer
Reset to default 7Read the coordinates (pageX
and pageY
) from the event object. Then use document.elementFromPoint(x, y)
to get the top element at that position.
本文标签: javascriptGetting current DOM object that touchmove or touchend is overStack Overflow
版权声明:本文标题:javascript - Getting current DOM object that touchmove or touchend is over - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742386941a2465222.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论