Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.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,我试图使其在单击时,该元素移动到“news-layout-1”元素中的第一个位置。到目前为止,我还没能让它工作。我尝试使用的实际脚本是一个RSS提要,因此我无法添加单个类名 <div class="news-layout-1"> <div class="item-post"><h1 class="item-title">First One</h1></div> <div class="item-post"><h

我试图使其在单击时,该元素移动到“news-layout-1”元素中的第一个位置。到目前为止,我还没能让它工作。我尝试使用的实际脚本是一个RSS提要,因此我无法添加单个类名

<div class="news-layout-1">
  <div class="item-post"><h1 class="item-title">First One</h1></div>
  <div class="item-post"><h1 class="item-title">Second One</h1></div>
  <div class="item-post"><h1 class="item-title">Third One</h1></div>
  <div class="item-post"><h1 class="item-title">Fourth One</h1></div>
  <div class="item-post"><h1 class="item-title">Fifth One</h1></div>
</div>

$(".item-post").click(function() {
    $($this).prependTo($(".item-post:first-of-type"));
});

第一个
第二个
第三个
第四个
第五个
$(“.item post”)。单击(函数(){
$($this.prependTo($(“.item post:first of type”);
});
小提琴:试试这个:-

$(".item-post").click(function() {
    $('.news-layout-1').prepend($(this));
});
试试这个:-

$(".item-post").click(function() {
    $('.news-layout-1').prepend($(this));
});
试试这个:-

$(".item-post").click(function() {
    $('.news-layout-1').prepend($(this));
});
试试这个:-

$(".item-post").click(function() {
    $('.news-layout-1').prepend($(this));
});

你想要这个@Kartikeya是的。谢谢把它作为答案贴出来,我会接受。你想要这个@Kartikeya是的。谢谢把它作为答案贴出来,我会接受。你想要这个@Kartikeya是的。谢谢把它作为答案贴出来,我会接受。你想要这个@Kartikeya是的。谢谢把它作为答案贴出来,我会接受的。