Javascript examples for jQuery Method and Property:append
Use appendTo to add element to parent
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.4.4.min.js"></script> <script type="text/javascript"> $(window).load(function(){//from w ww. ja v a 2 s. c o m $("div>img").each(function(){ $(this).appendTo($(this).parent()); }); }); </script> </head> <body> <div class="container"> <img src="http://www.java2s.com/style/demo/InternetExplorer.png"> <p>Hey</p> </div> <div class="container"> <img src="http://www.java2s.com/style/demo/Firefox.png"> <p>Hey</p> </div> </body> </html>