jQuery:如何删除div并将其放在其他地方?

J82*_*J82 6 jquery

<div id="wrapper">
     <div id="example1">
          <div id="navigation">
          </div>
     </div>
     <div id="example2">

     </div>
</div>
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,假设我要从#example1中删除#navigation并将其放在#example2中.我怎样才能使用jQuery来做到这一点?我只是使用remove和/ add或有更简单的方法吗?

amo*_*era 12

$("#navigation").appendTo("#example2");
Run Code Online (Sandbox Code Playgroud)

  • 还有`$("#navigation").appendTo("#example2").remove()` (5认同)