我不知道如何解决看似简单的问题。如果将鼠标悬停在专辑封面上,则会淡入(i)图标,如果您将鼠标悬停在(i)图标上,会出现一个工具提示,但它在1,2秒后不会停留在淡出状态。我如何解决这个问题,当鼠标悬停在(i)图标上并且当鼠标离开图标时fadesOut停留在工具提示上。Jquery鼠标事件
这里举例:http://www.midnightlisteners.com
我的代码:
// (i) Icon
$(".play, .more-info").mouseenter(function(){
clearTimeout($(this).data('timeoutIds'));
$(this).next(".more-info").fadeIn(600);
}).mouseleave(function(){
var someElement = $(this);
var timeoutIds = setTimeout(function(){
someElement.next(".more-info").fadeOut('150');
}, 1200); // giving a shorter time will reduce the fadeout effect
//set the timeoutId, allowing us to clear this trigger if the mouse comes back over
someElement.data('timeoutIds', timeoutIds);
});
//工具提示
$(".more-info").mouseenter(function(){
clearTimeout($(this).data('timeoutId'));
$(this).find(".the-tooltip").fadeIn('150');
}).mouseleave(function(){
var someElement = $(this);
var timeoutId = setTimeout(function(){
someElement.find(".the-tooltip").fadeOut('150');
}, 1200);
//set the timeoutId, allowing us to clear this trigger if the mouse comes back over
someElement.data('timeoutId', timeoutId);
});
这可能更适合于Code Review:http://codereview.stackexchange.com/ – calvinf
@calvinf:Code Review SE仅适用于工作代码。这似乎是一个调试/帮助问题。 – palacsint
@palacsint:好的,很好的信息,我会记住这一点。 – calvinf