开发者

Reset on Hover (jQuery)

$("#notification").slideDown("slow").delay(2000).slideUp("slow");

.. works, but I want to add a condition so that if #notification is hover开发者_如何学JAVAed, the timer/delay is stopped until mouseout. Then On mouseout the timer starts and then eventually the element is hidden (unless its not hovered again).

Thanks!


If I understand you correctly, you wanna be able to stop the delay/animation if you hover the element?

Use clearQueue() for that

$(document).ready(function() {
    if(cookieIsPresent) {
        $("#notification").hover(function() {
            $(this).stop(true, true).clearQueue(); // You might not need to use clearQueue() but test it out
        }, function() {
            $(this).delay(2000).slideUp("slow");
        }).slideDown("slow").delay(2000).slideUp("slow");
    }
});


Try handling the onmouseover (not onmousehover) event.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜