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.
精彩评论