title: Click to get index of array element with jquery
body: <p>Ok, I've tried my best at searching, but.
  I've got a task, where I need to load some js using the Ajax and so on. Long story short, I've stuck.</p>
  
  <p>First a code in script.js (which I must load AND which I can't modify):</p>
  
  <pre><code>var divs = [
      '&lt;div class="item"&gt;Lorem ipsum 0&lt;/div&gt;',
      '&lt;div class="item"&gt;Lorem ipsum 1&lt;/div&gt;',
      '&lt;div class="item"&gt;Lorem ipsum 2&lt;/div&gt;',
      '&lt;div class="item"&gt;Lorem ipsum 3&lt;/div&gt;',
      '&lt;div class="item"&gt;Lorem ipsum 4&lt;/div&gt;',
      '&lt;div class="item"&gt;Lorem ipsum 5&lt;/div&gt;',
      '&lt;div class="item"&gt;Lorem ipsum 6&lt;/div&gt;',
      '&lt;div class="item"&gt;Lorem ipsum 7&lt;/div&gt;'
  ];
  delete(divs[3]);
  </code></pre>
  
  <p>Then my script to load it</p>
  
  <pre><code>$.getScript('script.js', function() {
      $('.a').append('&lt;div class="yep"&gt;' + divs.join('') + '&lt;/div&gt;');
      $('.item').each(function() {
          $(this).click(function() {
              console.log( $('.item').index(this) );
          });
      });     
  });
  </code></pre>
  
  <p>The problem is that on click I need to get index of item in array, i.e. if I click on "Lorem ipsum 4" console should print "4", not "3" as it happens now (because of deleted element which doesn't appear in dom).
  Is there a way to get the right result using jQuery?</p>
  
  <p><strong>Ok, I need to say that it's a task. And here is the thing: I simply CAN'T modify script.js. Let's say it's on server and I have no access to it until I get it. But I need index of an element which it has in the original array.</strong></p>