- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use jQuery.wrapAll() method in jQuery?
The wrapAll() method wraps all the elements in the matched set into a single wrapper element.
Here is the description of all the parameters used by this method −
- elem − A DOM element that will be wrapped around the target.
Example
You can try to run the following code to learn how to use jQuery.wrapAll() method in jQuery −
<html> <head> <title>jQuery wrapAll() method</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $('ul.myclass > li:lt(2)').wrapAll('<div class="demo"></div>') }); </script> <style> .demo { border: 3px dashed blue; margin: 5px; } </style> </head> <body> <ul class="myclass"> <li>India</li> <li>US</li> <li>UK</li> <li>Australia</li> <li>Bangladesh</li> </ul> </body> </html>
Advertisements