Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jQuery在其同级中移动元素_Jquery - Fatal编程技术网

使用jQuery在其同级中移动元素

使用jQuery在其同级中移动元素,jquery,Jquery,我想在以下html中的“p”元素中移动图像: <div class="entery-post-excerpts"> <p>content1</p> <a href="#" class="alignrightthumb"><img width="210" height="158" src="http://imageurl"></a> </div> 或 似乎它不起作用。。。我如何才能做到这一点?那么您的问题是什么?

我想在以下html中的“p”元素中移动图像:

<div class="entery-post-excerpts">
<p>content1</p>
<a href="#" class="alignrightthumb"><img width="210" height="158" src="http://imageurl"></a>
</div>


似乎它不起作用。。。我如何才能做到这一点?

那么您的问题是什么?想知道哪一个更好吗?@Rajaparbhu。很抱歉给你带来了困惑。我编辑了我的问题。似乎它不起作用。我的脚本中有错误吗?你的代码应该可以工作@彼得:你能描述一下“它不起作用”吗。我发现我的html代码中有一个小错误(缺少引号)。现在,它的工作如预期。谢谢你的帮助。
<div class="entery-post-excerpts">
<p>content1<a href="#" class="alignrightthumb"><img width="210" height="158" src="http://imageurl"></a></p>
</div>
$('.alignrightthumb').each(function() {
$(this).appendTo($(this).parent().chidlren('p:first-child'));
});
$('.alignrightthumb').each(function() {
$(this).appendTo($(this).siblings('p'));
});