Switch child div to become parent - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:prepend

Description

Switch child div to become parent

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//ww  w .j  a va2s  .  co m
$('#parent1').prepend($('#child1'))
    });

      </script> 
 </head> 
 <body> 
  <div id="parent1">
    parent1 
  </div> 
  <div id="parent2"> 
   <div id="child1">
     some text in here 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials