Javascript 在博客文章列表中移动动态div

Javascript 在博客文章列表中移动动态div,javascript,css,each,Javascript,Css,Each,我正在使用一个博客,希望在每个帖子列表的标题上方移动类别。当我使用下面的代码时,我得到了50个第一类的克隆。我想我需要使用.each()的index参数,但我不确定。这是我的密码: jQuery(document).ready(function(){ jQuery(".blog-category").each(function(){ jQuery(this).insertBefore( jQuery(".blog-head") ) ; }); }); 基本上,我

我正在使用一个博客,希望在每个帖子列表的标题上方移动类别。当我使用下面的代码时,我得到了50个第一类的克隆。我想我需要使用
.each()
的index参数,但我不确定。这是我的密码:

jQuery(document).ready(function(){
    jQuery(".blog-category").each(function(){
        jQuery(this).insertBefore( jQuery(".blog-head") ) ;
    });
});
基本上,我正在尝试插入

.blog-category

.blog-head
在每个岗位上

HTML

<div id="entry-2839">
    <div class="blog-post-in">
        <div class="blog-head">content</div>
        <div class="blog-side">
            <div class="blog-category">more content</div>
        </div>
    </div>
</div>

内容
更多内容

这应该可以做到:

var e = jQuery(this);
e.closest(".blog-post-in").prepend(e);

这应该可以做到:

var e = jQuery(this);
e.closest(".blog-post-in").prepend(e);

你能发布一个HTML示例吗?
“xyzcontent”“morecontent”
你能发布一个HTML示例吗?
“xyzcontent”“morecontent”
。谢谢。sry为我在comment.worked中平淡无奇的html格式。谢谢。sry为我在评论中平淡无奇的html格式。