2014-11-25 93 views

回答

1

mouseenter对触摸屏不是有效的事件,从技术上讲,你没有鼠标。

在触摸屏上,建议绑定专用事件,如touchstart,touchendtouchmove

例如:

document.body.addEventListener('touchstart', function(e){ 
    alert(e.changedTouches[0].pageX) // alert pageX coordinate of touch point 
}, false) 

在这里看到更多的信息:http://www.javascriptkit.com/javatutors/touchevents.shtml

希望帮助。

+0

我认为这是一个有效的问题,但也许它没有被问得很对。我相信OP会询问如何在支持触摸的设备上支持鼠标事件。有许多触摸屏的笔记本电脑,但用户仍然有一个鼠标。 – 2015-07-28 18:19:46

+0

'touchenter'和'touchleave'事件不再有效。 – Shikkediel 2015-11-29 10:54:11

相关问题