複数のブログ記事を含むページで作業していますが、現在のプラットフォーム/テンプレートの制約により、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');
助けてくれてありがとう!