Wrap element in a div after creating it - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:wrap

Description

Wrap element in a div after creating it

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <meta name="viewport" content="width=device-width"> 
  <script src="https://code.jquery.com/jquery-3.1.0.js"></script> 
 </head> /*  w  w w.  j  a  v a2 s.  c  om*/
 <body> 
  <script>
    $(function(){
        $('<div class="dropdown" style="top: 50px; left: 50px;">test</div>').appendTo($('<div class="container"></div>').appendTo($("body")));
    });

      </script>  
 </body>
</html>

Related Tutorials