title: How to pass a reference to 'this' into a function?
body: <p>How do you reference a button by 'this' and pass it into a function?  </p>
  
  <pre><code>$(document).on("click", ".join-group-btn", function () {
                      var groupid=$(this).val();
                      var button=$(this);
                      joinGroup(groupid, button);
                  });
  </code></pre>
  
  <p>Then I keep the joinGroup function in my library on a separate page:</p>
  
  <pre><code>function joinGroup (groupid, buttonIn) {
      var button = $(buttonIn);
      var l = Ladda.create(document.querySelector(buttonIn));
  }
  </code></pre>
  
  <p>Id's won't work as the buttons are generated dynamically.</p>
  
  <p>This throws:</p>
  
  <pre><code>Dom exception 12: An invalid or illegal string was specified
  </code></pre>
  
  <p>Thanks for the help! It is greatly appreciated. </p>