0

我有一个简单的 jquery 函数,它在图像悬停时淡入淡出:

if($(".portfolioThumbs").length>0){
$(".magnify").css("opacity","0");
$(".magnify").hover(function(){$(this).stop().animate({opacity:1},"slow")},function()     {$(this).stop().animate({opacity:0},"slow")}
)};

如何在移动设备上获得同样的效果?我在某处读到你可以使用“touchstart”和“touchend”——如果是这样,我怎么能把它结合到这个函数中?

谢谢!

4

1 回答 1

0

也许这样的事情可以奏效。

var hoverStart = function(evt){
    $(this).stop().animate({
        opacity:1
    },"slow")
};
var hoverEnd = function(evt)     {
    $(this).stop().animate({
        opacity:0
    },"slow")
}
if($(".portfolioThumbs").length>0){
    $(".magnify").css("opacity","0");
    $(".magnify").bind('touchstart',hoverStart);
    $(".magnify").bind('touchend',hoverEnd);
    $(".magnify").hover(hoverStart, hoverEnd);
}
于 2013-01-25T04:59:54.200 回答