iPad悬停事件过程

时间:2010-08-30 10:51:34

标签: javascript events ipad hover

我正在为Apple iPad开发一个网站。在这里,我如何在mouseover上应用阴影以及如何在mouseout上删除?就像HTML a进程或Javascript提供的任何其他方式一样,我在这里使用jQuery ..有什么建议吗?

3 个答案:

答案 0 :(得分:1)

您可以尝试绑定click或touchstart-touchend事件。像这样:

//ipad and iphone fix
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) ||   (navigator.userAgent.match(/iPad/i))) {

     $(".menu li a").bind('touchstart', function(){
        console.log("touch started");
     });

     $(".menu li a").bind('touchend', function(){
        console.log("touch ended");
     });

}

答案 1 :(得分:0)

由于没有鼠标,也没有指针在屏幕上移动(除了一些越狱的iPad,但这是另一个故事),iPad的Safari从未触发过这些事件。 您可以将效果绑定到其他事件(如鼠标单击),但可能没有必要......

答案 2 :(得分:0)

切换到在mousedown和mousemove上应用悬停效果/阴影,并使用其他一些事件(定时mousedown / mouseup)或完全不同的按钮或触摸位置来“点击”。

请注意,如果隐藏在触摸下,某些效果可能永远不会被看到。