开发者

iPad hover event process

I am developing a site for Apple iPad. In this, 开发者_高级运维how can I apply shadow on mouseover and how to remove on mouseout? Like HTML a process, or any other way available with Javascript, I am using jQuery here.. any advice?


You can try to bind click or touchstart-touchend events. Like so:

//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");
     });

}


Since there's no mouse and no pointer that moves around the screen (except from some jailbreaked iPads, but that's another story), these events are never fired by iPad's Safari. You can bind the effects to other events (like mouse click) but maybe it's not necessary...


Switch to applying hover effects/shadow on mousedown and mousemove, and use some other event (a timed mousedown/mouseup), or a completely different button or touch location, for "clicking".

Note that some effects may never even be seen if they are hidden under the touch.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜