Retrieving an image source when another image is clicked?
<p>I am trying to retrieve the source of an image depending on which separate image the user previously clicked on.</p>

<pre><code>&lt;div class="card1"&gt;
    &lt;div&gt;
    &lt;a href="#" class="quickFlipCta"&gt;&lt;img class="back" src="Memory Pals/Test Pictures/QuestionMark.gif" /&gt;&lt;/a&gt;
    &lt;/div&gt;

    &lt;div&gt;
    &lt;a href="#" class="quickFlipCta"&gt;&lt;img class="front" src="Memory Pals/Test Pictures/flower.gif" /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;div class="card2"&gt;
    &lt;div&gt;
    &lt;a href="#" class="quickFlipCta"&gt;&lt;img class="back" src="Memory Pals/Test Pictures/QuestionMark.gif" /&gt;&lt;/a&gt;
    &lt;/div&gt;

    &lt;div&gt;
    &lt;a href="#" class="quickFlipCta"&gt;&lt;img class="front" src="Memory Pals/Test Pictures/flower.gif" /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>In my specific example, I am trying to retrieve the source of "front" when "back" is clicked. Also, it must retrieve the source of "front" in the same card. </p>

<p>This is what I've tried, but I can't get it to work:</p>

<pre><code>$(document).ready(function(){

        var found = 0;
        var last = null;

        $('img').each(function(index){
          $(this).attr('id','img-' + index);
        });    

        $('img').click(function(){
          if( last ) {
            if( ($(this).attr('src') == last.attr('src')) ) {
              $(this).css('visibility', 'hidden');
              last.css('visibility', 'hidden');
              found++;
            }
            if (found == 3) {
            window.location.href = "#play2"; 
            location.reload(); //resets found to 0
            }
            last = null;
          } else {
            last = $(this);
          }
        });
</code></pre>

<p>I realize it is not retrieving the source of "front," just the source of an image that the user has clicked on. How can I change it so it retrieves the source of "front" when "back" is clicked?</p>
