Something like (untested):

var myTimeout = null;

$('#myDiv').bind("mouseleave", function() {
    myTimeout = window.setTimeout(function() {
         $("#myDiv").slideUp(450);
    }, 1000);  // <-- 1000ms
});

$('#myDiv').bind("mouseenter",function() {
    window.clearTimeout(myTimeout);
});

When you mouseleave, it sets a 1000ms (1 second) timeout, which is
also stored as variable myTimeout. If you mouseenter again, it'll
clear that timeout so it won't execute.

On Apr 2, 2:59 am, wjp <waynep...@gmail.com> wrote:
> Hi,
>
> I have something like:
>
> $('#myDiv').bind("mouseleave",function() {
>     $('#myDiv).slideUp(450);
>
> })
>
> Essentialy I have a give that appears from a click event with some
> content. When the user mouses out of the div it slides away.
> However I'd like to have some for a delay so if the users mouse
> pointer leaves the div but comes back in within 1 sec the div does not
> slide up. THis is to stop the user from accidently moving the mouse
> out whilst moved down the contents of the div.
>
> Any ideas on how I could do this?
> thanks
> Wayne

Reply via email to