jQuery - mouseenter适用于chrome但不适用于firefox

时间:2012-12-28 16:09:39

标签: jquery

我有点jQuery:

$('#list_cont').on('mouseenter', '.show_map', function() {
    $(this).next('.map_cont').stop().fadeIn(800);
}).on('mouseleave', '.show_map', function() {
    if (!$(this).next('.map_cont').is(':hover')) {
        $(this).next('.map_cont').delay(600).stop().fadeOut(800);
    }
});

$('#list_cont').on('mouseenter', '.show_map', function() {
    $(this).stop().show();
}).on('mouseleave', '.map_cont', function() {
    $(this).delay(600).stop().fadeOut(800);
});

它在.map_cont mouseenter上显示.show_map,然后如果悬停在.map_cont上,则在光标离开.map_cont之前不会淡出。

这适用于Chrome,但不适用于Firefox。我不知道如何跨浏览器测试这种类型的东西。

1 个答案:

答案 0 :(得分:0)

由于.map_cont位于#list_cont内,所以它会这样做。因此,您需要以这种方式定义您的函数:

$('.map_cont').on('mouseleave', '.show_map', function() {
    if (!$(this).next('.map_cont').is(':hover')) {
        $(this).next('.map_cont').delay(600).stop().fadeOut(800);
    }
});