Перемещение элемента
Подскажите как правильно переместить элемент в пределах одного блока, а то все в кучу сбивается. Нужно span.price переместить в .blockBotton
jQuery('span.price').prependTo('.blockBotton'); <div class="product-info"> <div class="wrap-price"><span class="price">$200</span></div> <div class="blockBotton"></div> </div> <div class="product-info"> <div class="wrap-price"><span class="price">$300</span></div> <div class="blockBotton"></div> </div> <div class="product-info"> <div class="wrap-price"><span class="price">$250</span></div> <div class="blockBotton"></div> </div> |
face2005,
циклом по product-info |
face2005,
<!DOCTYPE html> <html> <head> <title>Untitled</title> <meta charset="utf-8"> <style type="text/css"> </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> jQuery(function() { jQuery(".product-info").each((i,d) => jQuery('span.price',d).prependTo(jQuery('.blockBotton', d))) }); </script> </head> <body> <div class="product-info"> <div class="wrap-price"><span class="price">$200</span></div> <div class="blockBotton"></div> </div> <div class="product-info"> <div class="wrap-price"><span class="price">$300</span></div> <div class="blockBotton"></div> </div> <div class="product-info"> <div class="wrap-price"><span class="price">$250</span></div> <div class="blockBotton"></div> </div> </body> </html> |
Спасибо большое!
|
Цитата:
$('span.price').each(function() { $(this).parent().next().append(this) }) |
Часовой пояс GMT +3, время: 10:26. |