title: Using '$(this)' In A Function
body: <p>I am creating a menu that opens and closes using jQuery. In simple terms, it works like this:</p>
  
  <pre><code>function open_menu() {
      $(this).next('ul.sub-menu').css('display', 'block').stop(true, false).animate({
          width: '235px',
      }, 500);
  }
  
  function close_menu() {
      // close code here
  }
  
  status = 'closed'; // set the default menu status
  
  $('a').click(function() {
      switch(status) {
          case 'closed':
              open_menu();
              break;
          case 'open':
              close_menu();
              break;
      }
  }
  </code></pre>
  
  <p>If I take the contents of <code>open_menu()</code> and put it in place of <code>open_menu()</code> in the <code>.click()</code> event, every works as expected. If I use the code as show above, <code>$(this)</code> can not figure out that <code>.click()</code> fired it and the code does not run.</p>
  
  <p>Is there something that I can do to have the <code>$(this)</code> selector negotiate what fired it while keeping it in <code>open_menu()</code>?</p>