How to add existing element attribute to child element while append that child element?
<p>here the HTML
span to be appended to this div</p>

<pre><code>&lt;div class="new"&gt;
    &lt;a value="03" id="a1"&gt;&lt;/a&gt;
    &lt;span&gt;&lt;/span&gt;
&lt;/div&gt;
</code></pre>

<p>ul contains element to show</p>

<pre><code>&lt;ul id="ad1" class="drpdwn"&gt;
    &lt;li value="1"&gt;
        &lt;input type="checkbox" value="2" id="ck1" name="Drop Shadows"/&gt;
        &lt;span id="sp1"&gt; Drop Shadows&lt;/span&gt;
    &lt;li&gt;
        &lt;input type="checkbox" value="2" id="ck2" name="Reflections"&gt;
        &lt;span id="sp2"&gt;Reflections&lt;/span&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a id="ck3" name="General Spotting" alt="1"/&gt;General Spotting&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a id="ck4" name="Gene Spotting" alt="1"/&gt; Spotting&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>Here The jQuery Code</p>

<pre><code>$('#ck2').click(function () {
    option = $('#sp2').text();
</code></pre>

<p>here id ck2 th attrbute are set to var ot</p>

<pre><code>ot=$('#ck2').attr("value");
    alert(ot);
</code></pre>

<p>here i set id ck2'th attr to appended span.help me out.!</p>

<pre><code>  $('.new span').append('&lt;span id="span1"&gt;&lt;/span&gt;').attr(ot);

  $('#span1').html(option);
  oc=$('#span1').attr("name" ,"value");
  alert(oc);
  })
</code></pre>
