title: "Disallow" execution of an event when another one is executing jQuery
body: <p>I have two events: one that is <code>onclick</code> which scrolls to certain div when I click on the menu and the other one in <code>onscroll</code> which &quot;highlight&quot; the menu item when the scroll is near to the div.</p>
  <p>My question is: how can I &quot;disallow&quot; the execution of one event while the other is executing.</p>
  <p>Here is my code:</p>
  <pre><code>function goToByScroll(id){
    var value = $(id).offset().top;
    var scrl = value - 154;
    $('html,body').animate({
      scrollTop: scrl},
    'slow');  
  } 
  
  //scroll menu control
  $(&quot;#menu-home ul li a&quot;).click(function(e) {
      e.preventDefault();
      $(&quot;#menu-home ul li a&quot;).removeClass('menu-home-active');
      $(this).addClass('menu-home-active');
      goToByScroll($(this).attr(&quot;href&quot;));    
  });
  
  //scroll bar control
  $(window).scroll(function() {
    var scrv = $(this).scrollTop();
    var allmenu = $(&quot;#menu-home ul li a&quot;);
    if(scrv == 0){
      allmenu.removeClass('menu-home-active');
      $('#menu-div1').addClass('menu-home-active');  
    }
    if(scrv &gt; 458 &amp;&amp; scrv &lt; 478){
      allmenu.removeClass('menu-home-active');
      $('#menu-div2').addClass('menu-home-active');  
    }
    if(scrv &gt; 989 &amp;&amp; scrv &lt; 1009){
      allmenu.removeClass('menu-home-active');
      $('#menu-div3').addClass('menu-home-active');  
    }
    if(scrv &gt;= 1324){
      allmenu.removeClass('menu-home-active');
      $('#menu-div4').addClass('menu-home-active');  
    }
  });
  </code></pre>
  <p>Thanks</p>