Here is my scenario:
<div class="item">
<div class="item-title">
<a href="_files/download_item.zip" class="link">Download 1</a>
</div>
<div class="item-description"> Lorem ipsum dolor…. </div>
</div>
What I want to do is to clone the anchor and append it to the "item-description" div.
The problem is when I have multiple items that the clone function then copies ALL of the anchors to ALL of the "item-description" divs.
Here is the jquery I am using:
$(function(){
$('a.link').clone(true).appendTo('.item-description');
});
Can anyone spot what I am doing wrong?
Try this:
$(function(){
$("a.link").each(function(){
$(this).clone(true).appendTo($(this).parent().siblings(".item-description"));
});
});