【发布时间】:2012-09-28 02:57:32
【问题描述】:
我正在处理包含多篇博客文章的页面,由于当前平台/模板的限制,无法移动 HTML 中的评论计数。
我想将 .reaction-count 元素从每篇文章的一部分移到另一部分。
我已阅读此线程上的解决方案:How to move an element into another element?,但我仍然不确定如何将其转化为我需要的解决方案。
这是我迄今为止尝试过的。它不太有效,因为它将所有 .reaction-count 元素移动到所有 .post-title 元素中,而不仅仅是该特定文章的 .reaction-count。
一次尝试: 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>
我尝试的第一件事之一:
$('.reaction-count').appendTo('.post-title');
提前感谢您的帮助!
【问题讨论】:
标签: jquery class dom element move