how to pass image source to <a> and <img> on closing a modal window?
<p>I've a page in which I've below code:</p>

<pre><code>&lt;div id="img-wrap"&gt;
&lt;a href="images/BIGGEST.JPG" class="MYCLASS" title="MYTITLE"&gt;  
    &lt;img src="images/SMALL.JPG" title="IMAGE TITLE"&gt;  
&lt;/a&gt;
&lt;/div&gt;
</code></pre>

<p>(say the images are 001-t.jpg for SMALL.jpg, 001.jpg for BIGGER.jpg, 001-b.jpg for BIGGEST.jpg)</p>

<p>on the same page I've a modal window which is having a BIGGER.jpg version of the same image.</p>

<pre><code>&lt;div id="mainImage"&gt;
    &lt;img src="images/BIGGER.JPG" /&gt; 
&lt;/div&gt;
</code></pre>

<p>Now what i would like to achieve on closing the modal window is... if the modal window has 002.jpg on closing the </p>

<pre><code>&lt;a href="images/BIGGEST.JPG" /&gt;
</code></pre>

<p>should be </p>

<pre><code>&lt;a href="images/002-b.JPG" /&gt;
</code></pre>

<p>and  </p>

<pre><code>&lt;img src="images/SMALL.JPG" /&gt;
</code></pre>

<p>should be </p>

<pre><code>&lt;img src="images/002.JPG" /&gt; 
</code></pre>

<p>say on the modal window the image changes dynamically. Any help is greatly appreciated. THanks!!</p>

<p>What I'm tried is:</p>

<pre><code>$('.window .close, #mask').click(function (e) {
        //Cancel the link behavior
        e.preventDefault(); 
        $('#mask,.window').hide();
        var currentSelection = $("#mainImage").attr("src");
        $(".MYCLASS img").attr("src",currentSelection);
        //alert(currentSelection);
        //var newHref = "images/";
        $('a.MYCLASS').attr("href",currentSelection); 
    }); 
</code></pre>

<p>but which is not working</p>
