1

複数のブログ記事を含むページで作業していますが、現在のプラットフォーム/テンプレートの制約により、HTML のコメント数を移動できません。

各記事のある部分から別の部分に .reaction-count 要素を移動したいと思います。

このスレッドの解決策を読みました:要素を別の要素に移動する方法は? しかし、それを必要なものに変換する方法はまだわかりません。

これが私がこれまでに試したことです。特定の記事の .reaction-count だけでなく、すべての .reaction-count 要素をすべての .post-title 要素に移動するため、うまくいきません。

1 回の試行: http://jsfiddle.net/DanEvans/jbgC4

別の試み: http://jsfiddle.net/DanEvans/jbgC4/5/

以下は、状況を模倣した単純化された HTML の例です。

<div class="entry-content">
    <h2 class="post-title">
        <a href="#">Post #1</a>
    </h2>

    <p>Lots of other text and elements</p>

    <span class="reaction-count">
        <br><a href="#">Post #1 Comments</a>
    </span>
</div>
<hr>
<div class="entry-content">
    <h2 class="post-title">
        <a href="#">Post #2</a>
    </h2>

    <p>Lots of other text and elements</p>

    <span class="reaction-count">
        <br><a href="#">Post #2 Comments</a>
    </span>
</div>​

私が最初に試したことの1つ:

$('.reaction-count').appendTo('.post-title');​

助けてくれてありがとう!

4

1 に答える 1

6

反応カウントを同じエントリコンテンツの投稿タイトルに移動しようとしているだけの場合。

$('.reaction-count').each(function(){
    $(this).parent().find('.post-title').append($(this));
});  ​  ​

(私のトラバースは間違っていました)。

個別に、リアクションカウントをその親エントリコンテンツ内の投稿タイトルに移動します。

含まれているCSSをいじる

于 2012-10-07T19:08:50.153 に答える