JQuery Wrap

 

The wrap() method is an inbuilt method in jQuery which is used to wrap the specified element around the selected element.

Syntax: $(selector).wrap(wrappingElement,function(index))

 
 
 
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> <script> $(document).ready(function(){ $(".container").wrap('<div class="wrapper"></div>'); $("button").click(function(){ $("p").contents().wrap("<em><b></b></em>"); }); }); </script> <style> button{ height: 40px; width: 300px; border-radius: 10px; } p{ color:darkturquoise } .wrapper{ padding: 20px; background: #11fff3; margin: 10px 0; } .container{ padding: 15px; background: rgb(192, 23, 23); font-size: 24px; } </style> </head> <body> <h1 style="color:deeppink">Click to button For wrap Appwrk Text</h1> <button type="button">Wrap Appwrk Blog</button> <div class="container"> <p>APPWRK IT Solutions is a complete Web Solutions Company offering customer-oriented web design services and more importantly, deliver them effectively. We can serve you well because we have the best combination of affordability and quality.</p> </div> </body> </html>
Output