reset setTimeout

I am using this javascript code:

function delayhidemenu() {

This code will hide some html code after 5 seconds.
It works fine.

But is it possible to reset/disable the settimeout after it has been set. I use the code when I move the mouse from a link -> like this: onmouseout="delayhidemenu()".

However when I go over the link again in the 5 seconds the html text will be still hidden after the 5 seconds!
That is not what I want it to be!

Can this be done?
Who is Participating?
knightEknightConnect With a Mentor Commented:
like this:

var myTimeoutID;

function delayhidemenu() {
    if (myTimeoutID)
    myTimeoutID = setTimeout("hideall()",5000);
set your timeout like this:

   var myTimoutID = setTimeout("hideall()",5000);

then clear it like this:


... just make sure that the variable myTimeoutID is global in scope (i.e., not local to the function that calls setTimeout).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.