title: how to pass $(this) object from one function to another?
body: <p>I think its very basic Object oriented javaScript related question. But I'm still very confused about it. I would like to pass $(this) object from 1 function to another. So that I can get the href attr of the link clicked.</p>
  
  <p>Here my sample code </p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;a href="#testblah" class="test" rel="image"&gt;TEST&lt;/a&gt;
  &lt;a href="#blahtest" class="test" rel="video"&gt;TEST&lt;/a&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>$(document).on("click", ".test", function () {
  
  var $this = $(this);
  var rel = $this.attr("rel");
  
  if (rel == "image") {
      e.preventDefault();
      openImage($this);
  } else if (rel == "video") {
      openVideo($this);
  }
  });
  
  function openImage($this) {
  
  var href =  $this.attr("href");
  alert(href);
  }
  </code></pre>