Loop through a set of ids and copy them
<p>I have an unordered list with ids like so:</p>

<pre><code>&lt;li id="e1"&gt;01&lt;/li&gt;
&lt;li id="e2"&gt;02&lt;/li&gt;
&lt;li id="e3"&gt;03&lt;/li&gt;
&lt;li id="e4" class="event_day"&gt;04&lt;/li&gt;
&lt;li id="e5" class="event_day"&gt;05&lt;/li&gt;
</code></pre>

<p>And a div with content like so:</p>

<pre><code>&lt;div id="descriptions"&gt;

&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;

&lt;/div&gt;
</code></pre>

<p>I want to copy the ids of the list items with the class event_day and assign them to the divs with a letter at the end so that they would become:</p>

<pre><code>&lt;div id="e4d"&gt;&lt;/div&gt;
&lt;div id="e5d"&gt;&lt;/div&gt;
</code></pre>

<p>I have come up with:</p>

<pre><code>$("#descriptions&gt;div").each(function() {
      $(this).attr("id", $(".event_day").attr("id") + "d");
});
</code></pre>

<p>But as you can probably tell, it does not loop and rather takes the first id and assigns it to all the divs resulting in:</p>

<pre><code>&lt;div id="e4d"&gt;&lt;/div&gt;
&lt;div id="e4d"&gt;&lt;/div&gt;
</code></pre>

<p>I'd highly appreciate it if you could explain the flaw in the logic and maybe even a link to something that I could read to improve my skills. I was looking at <a href="http://docs.jquery.com/Attributes/attr#keyfn" rel="nofollow">http://docs.jquery.com/Attributes/attr#keyfn</a> but it did not make sense. Thanks for reading!</p>
