2012-04-27 126 views
0

我想隐藏并使用悬停事件在fancybox2中显示标题,但它不起作用。请帮忙。显示/隐藏标题悬停fancybox2

我的代码是:

$("#fancybox-wrap").hover(function() { 
     $("#fancybox-title").show(); 
    }, function() { 
     $("#fancybox-title").hide(); 
    })}; 
+0

如果解决了这个问题,你应该接受一个答案,而不是更新问题标题。 – jrummell 2012-04-27 14:31:34

回答

0

你有一个额外的支架:

$("#fancybox-wrap").hover(function() { 
    $("#fancybox-title").show(); 
}, function() { 
    $("#fancybox-title").hide(); 
}); 
0

你必须使用类名;我建议使用'live'(所以你不需要为此使用回调) -

$(".fancybox-wrap").live({ 
    mouseenter: function() { 
     $(".fancybox-title").show(); 
    }, 
    mouseleave: function() { 
     $(".fancybox-title").hide(); 
    } 
}); 
+0

在http://api.jquery.com/live/中说:从jQuery 1.7开始,不推荐使用.live()方法。使用.on()附加事件处理程序。老版本的jQuery用户应优先使用.delegate(),而不要使用.live()。谢谢Janis – user1360770 2012-05-11 07:02:20

+0

是的,但不是每个人都在使用v1.7 + – Janis 2012-05-11 07:57:31