对于'touchstart'事件,是否有对应于e.PageX位置的事件,因为有点击事件? [英] Is there an equivalent to e.PageX position for 'touchstart' event as there is for click event?
问题描述
我试图用jQuery的touchstart事件获得X位置,与实时函数一起使用。
$('#box')。live('touchstart',function(e){var xPos = e.PageX;});
现在,这与'click'事件一起工作。如何在地球上(不使用 alpha jQuery Mobile)我有触摸事件吗?
感谢您的帮助。
但是你需要访问原始事件,而不是jQuery按摩的。此外,由于这些是多点触摸事件,还需要进行其他更改:
$('#box')。live ('touchstart',function(e){
var xPos = e.originalEvent.touches [0] .pageX;
});
如果你想要其他手指,你可以在触摸列表的其他索引中找到它们。
UPDATE FOR NEWER JQUERY:
$(document).on ','#box',function(e){
var xPos = e.originalEvent.touches [0] .pageX;
});
I'm trying to get the X position with jQuery of a touchstart event, used with the live function?
I.e.
$('#box').live('touchstart', function(e) { var xPos = e.PageX; } );
Now, this does work with 'click' as the event. How on earth (without using the alpha jQuery Mobile) do I get it with a touch event?
Any ideas?
Thanks for any help.
Kinda late, but you need to access the original event, not the jQuery massaged one. Also, since these are multi-touch events, other changes need to be made:
$('#box').live('touchstart', function(e) {
var xPos = e.originalEvent.touches[0].pageX;
});
If you want other fingers, you can find them in other indices of the touches list.
UPDATE FOR NEWER JQUERY:
$(document).on('touchstart', '#box', function(e) {
var xPos = e.originalEvent.touches[0].pageX;
});
这篇关于对于'touchstart'事件,是否有对应于e.PageX位置的事件,因为有点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!