title: setTimeout() and setting parameters
body: <p>I have some jQuery code that looks like this:</p>
  
  <pre><code>$('.mainNav2 &gt; li').mouseleave(function(){
      var someNum = Math.random();
      $(this).attr('id', someNum);
      var t = setTimeout("HideMenu(someNum)", 200);
      $('li.clicked').mouseenter(function() {
          clearTimeout(t);
      });
  });
  
  function HideMenu(id) {
      $('#'+id).removeClass('clicked');
  }
  </code></pre>
  
  <p>It's purpose is to hide a mega menu on mouse leave, but also takes into account accidental mouse leaves, by using a 300 millisecond setTimeout.  If the user brings the mouse pointer back into the li within 300 milliseconds, the menu is not hidden because clearTimout(t) is called. </p>
  
  <p>The problem is when the user DOES intent to mouseout, the function in the setTimout is not being called. According to this page: <a href="http://www.w3schools.com/js/js_timing.asp">http://www.w3schools.com/js/js_timing.asp</a> my syntax is correct, but I can only get the HideMenu function called from the setTimeout if I write it like this:</p>
  
  <pre><code>var t = setTimeout(HideMenu, 300);
  </code></pre>
  
  <p>Why isn't it working as written, where I can pass a variable into the function as a parameter?</p>