перемещение картинки методами jquery
Здравствуйте, как методами jquery переместить картинку из одного блока в блок с другим классом? при выполнении определенного условия
|
Например, так:
<div class="div1"> <img alt="" src="img.png" /> </div> <div class="div2"></div> var img = $('.div1 > img'); img.clone().appendTo('.div2'); img.remove(); |
Я пытаюсь переместить каждый появляющийся динамически блок с классом portfolio_img в новый блок portfolio_img_height
<div class="portfolio_img"> <a class="fancybox" href="<?=$value['photo'];?>" data-fancybox-group="gallery" title="<?=$value['title'];?>"> <img class="fancybox_img" src="<?=$value['thumb'];?>" alt="" /> </a> </div> <div class="portfolio_img" id="portfolio_img_height"> </div> var obj = $('.fancybox_img'); jQuery.each(obj, function(i, val) { $(this).parent('.portfolio_img').detach().prependTo('#portfolio_img_height'); }) Но все остается на своих местах |
Цитата:
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <!-- <link rel="stylesheet" type="text/css" href="tmp.css" /> --> <style type="text/css"> .portfolio_img { border: 1px solid; } </style> <script type="text/javascript"> $(function (){ $('.fancybox_img').each(function() { $(this).parents('.portfolio_img').prependTo('#portfolio_img_height'); }) }); </script> </head> <body> <div class="portfolio_img"> <a class="fancybox" href="<?=$value['photo'];?>" data-fancybox-group="gallery" title="<?=$value['title'];?>"> <img class="fancybox_img" src="http://javascript.ru/forum/images/smilies/smile.gif" alt="" /> </a> </div> <div class="portfolio_img" id="portfolio_img_height"></div> </body> </html> |
Часовой пояс GMT +3, время: 03:17. |