jQuery将元素移动到同级不工作

jQuery将元素移动到同级不工作,jquery,html,Jquery,Html,我正在尝试分离一个元素并将其前置到一个同级元素,但什么都没有发生,控制台中也没有出现任何错误 这是我的HTML: <div class="wp-posts-carousel-container"> <div class="wp-posts-carousel-image"><a href=" /?event=7-nights-450-2" title="Read more

我正在尝试分离一个元素并将其前置到一个同级元素,但什么都没有发生,控制台中也没有出现任何错误

这是我的HTML:

<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&nbsp;to 23rd Feb&nbsp;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 &amp; 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>
这根本没用,有人知道发生了什么吗?

这:

 $(".event-date-visit").each(function() {
  $(this).detach().prependTo($(this).closest('.wp-posts-carousel-image')); 
 });
事实并非如此。因为当.wp发布旋转木马图像时,最接近的是工作的

$(“活动日期访问”)

相反,您可以这样做:

 $(".event-date-visit").each(function() {
   $(this).detach().prependTo($(this).closest('.wp-posts-carousel-details').prev()); 
 });

您可以使用此选项,例如:

$(".event-date-visit").each(function() {

      $(this).prependTo($(this).parent().parent().prev()); 
 }); 
不要使用detach(),因为您将丢失$(此)


演示:

是的,好吧,这就是问题所在,但解决方案是什么?这仍然没有任何作用。这一个对我有效,其他答案都无效。
$(".event-date-visit").each(function() {

      $(this).prependTo($(this).parent().parent().prev()); 
 });