【问题标题】:Move element out of its containing div to another将元素从其包含的 div 移到另一个
【发布时间】:2013-06-19 15:22:01
【问题描述】:

我正在构建一个添加了自定义 Tiny MCE 样式的 wordpress 网站,它为用户提供了一个包含锚点的预样式“更多”按钮,该按钮位于帖子的左下方。更多按钮的格式是这样的

<p><span class="moreButton"><a>Link here </a></span></p>.

我的问题是将框设置为动态大小,无论其中有多少文本,并且由于通过 wordpress 帖子输入的按钮样式更多,它包含在我似乎无法释放的 div 中从。

总而言之是这样的:

<div class="newsBoxMore">
        <div class="newsBoxMainHolder">

        <div class="alumniHeading newsMainHeading">
        <h4>21 Years of NCCA Masters</h4>
        </div>

        <div class="alumniContent newsMainContent">
                    <p>As a reminder of where we started out this example from 1990 won a special award at the CG90 Festival.</p>
<p>Text in here.</p>
<p><span class="moreButton"><a title="Video" href="" target="_blank">View Here</a></span> </p>

        </div><!-- end newsMainContent -->

        <div class="newsDateHolder">
            <p>POSTED: 16.06.13</p>
        </div><!-- end newsDateHolder -->

        </div><!-- end newsBoxMainHolder -->

    </div><!-- end news Box More -->

我想做的是移动

<p><span class="moreButton"></span></p> 

在 newsMainContent div 之外,我希望它位于 newsDateHolder div 上方。我尝试使用以下代码:

$(".newsMainContent span").insertAfter($(".newsMainContent"));

这样做的问题是它与页面上的每个锚点都复制了 moreButton 类。所以我最终得到了一个应该有一个 moreButton 的帖子,但现在它有 10 个,因为该页面显示了 10 个帖子。

任何帮助将不胜感激!

【问题讨论】:

    标签: php jquery wordpress tinymce insertafter


    【解决方案1】:

    您需要在唯一 ID 之后提供您想要的元素,并使用它而不是类。

    【讨论】:

    • 那没用,不是每个帖子上都有多个框,现在只有多个框了
    • 为您正在使用的两个元素提供一个 ID。你想在一个地方插入一个按钮。
    • 哇,效果很好,太棒了。唯一的事情是,我需要将其应用于大量按钮,因为每个帖子都有自己的按钮,从技术上讲,我不能重用大量的 id。我也使用这个给按钮它的类 - array('title' => 'More Button', 'inline' => 'span', 'class' => 'moreButton') 它不会让我转动它们全部进入Divs!
    • 我误解了 - 所以对于每个跨度,它需要在它的父 div 之后移动到?
    猜你喜欢
    • 2012-06-09
    • 1970-01-01
    • 2011-11-06
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-07
    相关资源
    最近更新 更多