Friday, 23 August 2013

jquery : how to apply same changes inside mulitple container with same class name

jquery : how to apply same changes inside mulitple container with same
class name

i am trying to move a .details outside of .buttons
<div class="product-actions">product 1
<div class="buttons buttons_3 group">buttons
<a class="details" title="Détails" rel="nofollow" >link</a>
</div>
</div>
<div class="product-actions">product 2
<div class="buttons buttons_3 group">buttons
<a class="details" title="Détails" rel="nofollow" >link</a>
</div>
</div>
this do the trick
if ($('.product-actions').length )
{
$('.product-actions').prepend("<div id='new_details_location'></div>");
$(".details").prependTo("#new_details_location");
$('.buttons_3').attr('class','buttons buttons_2 group');
}
the problem is there is more than one product and all a.details get moved
to the first product div instead of being prepend at the beginning of each
div .product-actions:
http://jsfiddle.net/upKhq/2/ any idea?

No comments:

Post a Comment