jQuery: Move attributes between elements
<p>I have this HTML markup</p>

<pre><code>&lt;a href="#" title=""&gt;
   &lt;img src="#" title="image1" /&gt;
&lt;/a&gt;

&lt;a href="#" title=""&gt;
   &lt;img src="#" title="image2" /&gt;
&lt;/a&gt;

&lt;a href="#" title=""&gt;
   &lt;img src="#" title="image3" /&gt;
&lt;/a&gt;
</code></pre>

<p>and I need to take the title of each image and put it on their "a". I tried to do it with this function</p>

<pre><code>   $(function() {

    var title = $('a').find('img');

    var updateTitle = title.attr('title');

    $('a').attr({
      title: updateTitle,
      alt: 'lol'
     });
 });
</code></pre>

<p>But the only result is the same title for all "a" (the first title he finds)</p>

<p>Any help????</p>

<p>Thank you very much</p>
