title: Getting the current script DOM object in a (jquery) ajax request
body: <p>I have a html component that includes some javascript. </p>
  
  <p>The component is a file in a template engine, so it can be used</p>
  
  <ul>
  <li>in the initial rendering of the whole html page</li>
  <li>as stand-alone html rendered through an ajax request</li>
  </ul>
  
  <p>The javascript should be applied to an object in the template, i.e. :</p>
  
  <pre><code>&lt;div class="grid" &gt;
    &lt;div class="item" id="item_13"&gt;
        This is item 13
    &lt;/div&gt;
    &lt;div class="item" id="item_14"&gt;
        This is item 14
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function(){
         $(HOW_DO_I_GET_PREVIOUS_ELEMENT???).someEffect(params)
      })
  &lt;/script&gt;
  </code></pre>
  
  <p>I've checked <a href="https://stackoverflow.com/questions/403967/how-may-i-reference-the-script-tag-that-loaded-the-currently-executing-script">this similar question</a> but the best answers seem to rely on the current script being the last one in the 'scripts' variable as the next ones are not loaded yet. If I append the html and js with an ajax request, it will not be the case.</p>
  
  <p>To be 100% clear : the question is about getting the previous object WITHOUT reference to any specific attribute : no unique id for the  tag, no random id as there is theoretically always a chance it will show up twice, no unique class attribute,as exactly the same component could be displayed in another part of the HTML document.</p>