在其中剪切一个div和html并使用jquery将其粘贴到另一个div中 [英] cut a div and html inside it and paste it into a different div with jquery

查看:323
本文介绍了在其中剪切一个div和html并使用jquery将其粘贴到另一个div中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个第三方脚本,在该脚本中我无法控制html,并且只能修改基本的CSS.我只是想知道是否有可能剪切div和其中的所有html,并在页面加载后立即将其粘贴到其他div中?

I have a 3rd party script in which i have no control over the html and can only modify basic css . I just wanted to know if its possible to cut a div and all the html inside it and paste it in a different div as soon as the page loads?

假设我们有

  <div id="example-one">
      <ul class="nav">
         <li class="nav-one"><a href="#featured" class="current">Billing Address</a></li>
      </ul>
      <div class="list-wrap">
          hello
      </div>
  </div>

,当页面加载时,jQuery将剪切整个html,并指定div ID "example-one",并将其粘贴到新的div名称中,即为"new-div".这可能吗?

and when the page loads jquery cuts the whole html specifying the div id "example-one" and paste it into a new div name it be "new-div". Is this possible ?

推荐答案

你好,我能够找到我的问题的答案,我尝试了一个jquery函数,它就像一个魅力一样工作,就像我想要粘贴代码那样,对于任何一个像我这样有确切问题的人都是有用的.

Hello i was able to find the answer to my question i tried one jquery function and it worked like a charm like i wanted i am pasting the code so that it can be useful to anyone who has exact problem as of mine .

jQuery(document).ready(function(){
$('#div1').insertAfter('.div2');
});

这将剪切div1 html并将其移至div2

This will cut the div1 html and move it to div2

这篇关于在其中剪切一个div和html并使用jquery将其粘贴到另一个div中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆