jquery - Javascript: clearTimeout seems to only suspend, not reset or clear? -


i new js , trying modify javascriptkit jquery-based megamenu system delay showing menu until mouse has been hovering on anchor object specified time.

the problem facing right seems cleartimeout called on mouseout suspends settimeout, rather canceling, clearing, resetting it.

at point showing alert after settimeout call. have timeout interval set 2000 testing.

as example, since have set 2 seconds delay right now, if mouse on object 4 times 1/2 second, 5th time mouse on object test alert box appears instantly.

i thought cleartimeout supposed destroy timed event. why appear pause countdown?

teststuff:function(){     if(jkmegamenu.toggletest==1)      {          jkmegamenu.executetimedcommand()          jkmegamenu.toggletest=0      }     else      {          //jkmegamenu.executetimedcommandcancel()          cleartimeout(jkmegamenu.teststuff);      }     },      executetimedcommand:function(){         if(jkmegamenu.toggletest==1)         {             alert('abcde')         }     },      canceltimedcommand:function(){     cleartimeout(jkmegamenu.teststuff); }, 

cleartimeout takes timer id parameter, not function reference.

for example, if you're setting timeout jkmegamenu.teststuff, this

// set delayed call var timerid = settimeout(jkmegamenu.teststuff, 2000);  // cancel cleartimeout(timerid); timerid = 0; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -