简体   繁体   English

div 向上或向下移动

[英]Div move up or down

Good morning.早上好。

I'm having a doubt.我有一个疑问。 Anyone know to do to move a div down or up?...任何人都知道如何将 div 向下或向上移动?...

My example code.我的示例代码。 Over the div I want to pass up and 3 before the div click, then will be up 4 div.在 div 上,我想在 div 点击之前向上传递 3,然后将向上 4 div。 Anyone know how I can make the selection of this div任何人都知道我如何选择这个 div

$(".up").click(function(){
  $(this).parent().prev().prev().prev().insertBefore($(this).parent().prev())
});

HTML HTML

 <div class="1" >
     <div class="2">
        <div class="3">
           <div class="4">
              <div class="up">UP</div> 
           </div>
        </div>
     </div>
   </div>
 <div class="1" >
     <div class="2">
        <div class="3">
           <div class="4">
              <div class="up">UP</div> 
           </div>
        </div>
     </div>
   </div>

I would be very grateful for the help.我将非常感谢您的帮助。

$(".up").click(function() {
    $(this).parents(".1").insertBefore($(this).parents(".1").prev(".1"));
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM