title: Change variable based on which element is clicked
body: <p>It is possible to change variable inside function which is based on element is user clicks?
  In my case this will fully work for one kind of menu but I need two fully identical menu 
  with one difference - 
  second click handler must load toggleDrawer with changed $sidebar to $navbar variable.</p>
  
  <pre><code>    /*
      Variables
      */
  
      var $sidebar = $('#sidebar'),  
          $navbar = $('#navbar'),
          drawerOpen = false,
  
      /*
      Functions
      */
  
      closeDrawer = function() {
          drawerOpen = false;
          $body.css('overflow','').removeClass('sidebar-open');
          $sidebar.removeClass('open');
          $sidebar.animate({'right':'-50%'},{duration:300});
          $(this).hide();
  
      },
  
      openDrawer = function() {
          drawerOpen = true;
          $body.addClass('sidebar-open').css('overflow','hidden');
          $sidebar.addClass('open');
          $sidebar.animate({'right':'0%'},{duration:300});                
      },
  
      toggleDrawer = function() {
          if (drawerOpen) {
              closeDrawer();
          }else{
              openDrawer();
          }
      },
  
      /*
      Bind Events
      */
  
      $document.on('click', '.drawer-toggle-sidebar', function(event){
          toggleDrawer();
          event.preventDefault();
      });
  
      $document.on('click', '.drawer-toggle-navbar', function(event){
          toggleDrawer();
          event.preventDefault();
      });
  </code></pre>