我正在尝试分离并将一个元素添加到兄弟元素中,但没有任何事情发生,我也没有在控制台中出现任何错误。
这是我的HTML:
user_timeline
jQuery的:
<div class="wp-posts-carousel-container">
<div class="wp-posts-carousel-image"><a href=" /?event=7-nights-450-2"
title="Read more 7 Nights - £450"><img alt="7 Nights - £450"
style="max-width:100%;max-height:100%"
src=" /wp-content/uploads/2016/10/5e87ac4c-5a68-4206-bebc-51163a92a204-150x150.jpg"></a>
</div>
<div class="wp-posts-carousel-details"><h3 class="wp-posts-carousel-title"><a
href=" /?event=7-nights-450-2" title="7 Nights - £450">7 Nights - £450</a></h3>
<div class="wp-posts-carousel-desc"><span class="event-date-visit" style="font-size: 10pt;"><strong>16th Feb to 23rd Feb 2017</strong></span>
<ul class="chevrons icon ">
<li><i class="fa fa-check"></i><i class="icon icon-envelope-alt"></i> 4* Hotel</li>
<li><i class="fa fa-check"></i><i class="icon icon-film"></i> Daily breakfast & dinner buffet</li>
<li><i class="fa fa-check"></i><i class="icon icon-envelope-alt"></i> All ground transfers</li>
<li><i class="fa fa-check"></i><i class="icon icon-film"></i> Guided tours to many historical sites</li>
</ul>
Flights not included - approx £200
</div>
<p class="wp-posts-carousel-buttons"><a href="/contact"
class="wp-posts-carousel-more-button button btn btn-primary"
title="Read more 7 Nights - £450">Enquire Now</a></p>
<p></p></div>
</div>
这一点都没有,任何人都知道发生了什么事?
答案 0 :(得分:1)
您可以使用此功能,例如:
$(".event-date-visit").each(function() {
$(this).prependTo($(this).parent().parent().prev());
});
不要使用detach(),因为你会松开$(this)。
答案 1 :(得分:0)
这:
$(".event-date-visit").each(function() {
$(this).detach().prependTo($(this).closest('.wp-posts-carousel-image'));
});
不是真的。因为当 .wp-posts-carousel-image 是
的父级时,最近的是有用的<强> $(&#34; .event最新访&#34)强>
相反,你可以这样做:
$(".event-date-visit").each(function() {
$(this).detach().prependTo($(this).closest('.wp-posts-carousel-details').prev());
});