How to find the position of the certain element inside a div?
<p>I am trying to find the image position inside my div</p>

<p>my Html</p>

<pre><code>&lt;div&gt;
  &lt;p&gt;test&lt;/p&gt;
  &lt;img src='test1.jpg'/&gt;  
  &lt;p&gt;test&lt;/p&gt;
  &lt;p&gt;test&lt;/p&gt;  
  &lt;img src='test2.jpg'/&gt;  
  &lt;p&gt;test&lt;/p&gt;
  &lt;img src='test2.jpg'/&gt;  --the user clicks this image and I want to know the time it appears. In this case, 2 is what I need.
  &lt;p&gt;test&lt;/p&gt;
  &lt;img src='test2.jpg'/&gt;
  &lt;p&gt;test&lt;/p&gt;
&lt;/div&gt;
</code></pre>

<p>I have</p>

<pre><code>var imagePosition=0;
$('img').click(function(){
     var imgSource=$(this).attr('src');
    $(this).closest('div').find('img').each(function(){
       if($(this).attr('src')==imgSource){
          imagePosition++;
       }
    })
})
</code></pre>

<p>I can find out how many time the same images appear but I can't tell which image the user clicks and it's position. Are there anyways to do this? Thanks so much!</p>
