title: javascript only closest element from a function call
body: <p>I am trying to find a way to get an element by className closest to the function is being called on document load.</p>
  
  <p>I found .closest() but it requires an element selector.</p>
  
  <p>As function is being called randomly and don't have a specific location on DOM. </p>
  
  <p>So if I could get element of the current running function script tag</p>
  
  <p>I know document.currentScript but apparently its not working inside a function: </p>
  
  <p><a href="https://jsfiddle.net/ow240m2p/" rel="nofollow noreferrer">https://jsfiddle.net/ow240m2p/</a></p>
  
  <p>also script.length - 1 is getting wrong elemnt as function is being called after document load:</p>
  
  <pre><code>var scriptTag = document.getElementsByTagName('script');
  scriptTag = scriptTag[scriptTag.length - 1];
  </code></pre>
  
  <p>I could assign ID to the script tag but I am trying to find a way without ID</p>