I have a jQuery function which when run wrapped in a click handler, works nicely. It causes a notification div at the top of the screen, to gracefully slide up out of the view port.
The problem is that when I run the same function inside a timeout (so that if the user doesn't click the message to remove it, it will remove itself after 8 seconds), it doesn't slide but is just removed suddenly after 8 seconds.
This is the function in the timeout that isn't working correctly:
- setTimeout(function(){
$(this).animate({top: -$(this).outerHeight()}, 500);
hideAllMessages(); - },8000);
and this one is the same function in a click handler, which works fine.
- $('.message').click(function(){
$(this).animate({top: -$(this).outerHeight()}, 500);
hideAllMessages(); - });
Can anyone explain why this might be happening please?
Many thanks.
Peter
A Linux Admin
Willing to help maintain Linux servers remotely for a tiny consideration into my Paypal account :-)