title: How to add parameters to this javascript/jquery function?
body: <p>This script allows you to click an element all you want, but when you click anything but that element, it fades something out. In my code below I can click all I want inside of <code>$('.wrapper')</code> and nothing happens, but when I click anything outside of that element, I have <code>$('.popup')</code> fadeOut.</p>
  
  <pre><code>(function hideElementOnOffClick(elementWrapper, elementToHide) {
  
      $(document).bind('click', function(evnt) {
          var $target = $(evnt.target);
  
         if ($target.is(elementWrapper) || elementWrapper.has(evnt.target).length) {
              return;
          }
  
          elementToHide.fadeOut();
      });
  })(); 
  </code></pre>
  
  <p>then I call the function with the two element classes in it:</p>
  
  <pre><code>hideElementOnOffClick($('.wrapper'), $('.popup'))
  </code></pre>
  
  <p>It works find if I use <code>$('.wrapper')</code> instead of elementWrapper and <code>$('.popup')</code> instead of elementToHide, but when I make it into something I can call on in different places with different classes, it doesn't.</p>
  
  <p>How do I fix the parameters so that this works?
  ​</p>