Add div after an element - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:wrapAll

Description

Add div after an element

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-2.1.0.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//from ww w .j a va2s  .c o  m
$("p").next().andSelf().wrapAll('<div id="test" />');
    });

      </script> 
   </head> 
   <body> 
      <h2>test</h2> 
      <p>test</p> 
      <ul> 
         <li>testlijst</li> 
      </ul>  
   </body>
</html>

Related Tutorials