【发布时间】:2013-02-20 13:20:54
【问题描述】:
我在我的项目中使用了 taphold 事件,需要用户点击的点的坐标。不幸的是,event.clientX 和 event.clientY 是未定义的(cp。我的例子here)。 是否有可能获得类似于 onclick-event 的这些坐标?
提前致谢!
【问题讨论】:
标签: javascript jquery jquery-mobile
我在我的项目中使用了 taphold 事件,需要用户点击的点的坐标。不幸的是,event.clientX 和 event.clientY 是未定义的(cp。我的例子here)。 是否有可能获得类似于 onclick-event 的这些坐标?
提前致谢!
【问题讨论】:
标签: javascript jquery jquery-mobile
你需要作弊,我为你做了一个工作示例:http://jsfiddle.net/Gajotres/STLWn/
$(document).on('vmousedown', function(event){
holdCords.holdX = event.pageX;
holdCords.holdY = event.pageY;
});
$(document).on('taphold', function(e){
alert('X: ' + holdCords.holdX + ' Y: ' + holdCords.holdY );
});
var holdCords = {
holdX : 0,
holdY : 0
}
在桌面 Firefox、Android 4.1.1 Chrome 和 iPad 6.0 上测试
【讨论】: