jQuery | wrapAll() with Examples
The wrapAll() method is an inbuilt method in jQuery which is used when the specified element will wrapped against all the selected elements.
Syntax:
$(selector).wrapAll(wrap_element)
Parameters: This method accept single parameter wrap_element which is mandatory. This parameter is used to specify that which element get wrapped around the selected element.
Return Value: This method returns the selected elements with the specified changes made by wrapAll() method.
Below example illustrates the wrapAll() method in jQuery:
Example:
<!DOCTYPE html> <html> <head> <title>The wrapAll Method</title> <script src= </script> <!-- jQuery code to show the working of this method --> <script> $(document).ready(function() { $("button").click(function() { $("p").wrapAll("<div></div>"); }); }); </script> <style> div { background-color: lightgreen; padding: 20px; width: 200px; font-weight: bold; height: 60px; border: 2px solid green; } </style> </head> <body> <!-- click on this paragraph and see the change --> <p>Welcome to GeeksforGeeks!<br><br> <button>Click Here!</button></p> </body> </html> |
Output:

Recommended Posts:
- jQuery | last() with Examples
- jQuery | on() with Examples
- jQuery | first() with Examples
- jQuery | after() with Examples
- jQuery | has() with Examples
- jQuery | one() with Examples
- jQuery | val() with Examples
- jQuery | eq() with Examples
- jQuery | resize() with Examples
- jQuery | replaceWith() with Examples
- jQuery | replaceAll() with Examples
- jQuery | removeProp() with Examples
- jQuery | mousemove() with Examples
- jQuery | scrollLeft() with Examples
- jQuery | scrollTop() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



