title: How to stop window.scroll() after specific event
body: <p>I am using bootstrap collapse() script to expand/collapse a div. I want to append window.scroll() method on .hidden() and stop the window.scroll() in .shown(). But the window.scroll() always append to that div.</p>
  
  <p>My code snippet</p>
  
  <pre><code>    $('body').delegate('#div1', 'shown', function() {
      $('#label').children('i').removeClass('icon-plus-sign');
      $('#label').children('i').addClass('icon-minus-sign');
      $(window).scroll(function(e) {
          e.preventDefault();
          e.stopPropagation();
      });
  });
  
  $('body').delegate('#div1', 'hidden', function() {
      $('#label').children('i').removeClass('icon-minus-sign');
      $('#label').children('i').addClass('icon-plus-sign');
      $(window).scroll(function() {
          var scrollTop = $(window).scrollTop();
          $('#content').stop().animate({
              "marginTop": (scrollTop + '40px;' : (scrollTop) + "px" }, "slow");
      });
  })
  </code></pre>