views:

53

answers:

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

.. works, but I want to add a condition so that if #notification is hovered, 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!

+2  A: 

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");
    }
});
Marko
erm..how should the whole thing look with slidedown/slideup and delay too?
Nimbuz
Hi @Nimbuz - see my edit
Marko
Perfect. Thank you sir! ;)
Nimbuz
You're welcome :) Try removing the clearQueue and see if that works, I've heard that stop() might not work on delay() but that might've been fixed.
Marko
A: 

Try handling the onmouseover (not onmousehover) event.

Sidharth Panwar
You could try put a bit more effort into the answer. P.S. There's no onmousehover event.
Marko
Misspelled the event.
Sidharth Panwar