如果我通过触摸屏点击链接,我正在努力解决IE11上的jQuery mouseleave事件。每次我通过触摸点击链接时,mouseleave
事件会在之后触发,但我不会在其他地方点击。在Chrome和FF上,它可以正常工作,因为它们会重新定位实际的光标位置,而IE会将它留在前一个位置。
请参阅以下脚本 - 适用于FF和Chrome中的触摸屏,以及使用鼠标。 http://jsfiddle.net/daSL2/
预期行为:mouseleave
事件只有在我用鼠标移开或通过触摸屏点击其他地方时才会触发。 (经过联想瑜伽13测试)
JS:
$(function () {
$('a').on({
click: function (e) {
writeDebugText('click');
},
mousedown: function (e) {
writeDebugText('mousedown');
},
mouseenter: function (e) {
writeDebugText('mouseenter');
},
mouseleave: function (e) {
writeDebugText('mouseleave');
}
});
});
var last = new Date();
function writeDebugText(text) {
var o = $('div.Debug');
var now = new Date();
var diff = now.getTime() - last.getTime();
o.html(text + " @ " + diff + " <br /> " + o.html());
last = now;
}
HTML:
<a href="#" style="-ms-touch-action: none; touch-action: none;">Click me</a>
<hr />
<em>
<div class="Debug"></div>
</em>
感谢您的帮助!