获得元素下的元素 [英] Get the element under a touchend
本文介绍了获得元素下的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当 touchend
事件绑定到触发 touchstart
的元素时,如何获取元素在手指离开的位置,当它位于事件被绑定到的元素之外时。
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.
推荐答案
你可以使用 document.elementFromPoint
方法,传递事件的坐标:
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
);
});
编辑:
找到一些关于获取元素的好文章具体坐标。
http://www.zehnet。 de / 2010/11/19 / document-elementfrompoint-a-jquery-solution /
这篇关于获得元素下的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文