- Trending Categories
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 wrap tables with div element using jQuery?
To wrap tables with div element, use the wrap() method. You can try to run the following code to wrap tables with div element using jQuery −
Example
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#button1").click(function(){ $('table').wrap('<div></div>'); }); }); </script> <style> div { background-color: gray; } </style> </head> <body> <table style="width:100%"> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Will</td> <td>Smith</td> <td>50</td> </tr> <tr> <td>Eve</td> <td>Jackson</td> <td>94</td> </tr> </table> <button id="button1">Wrap</button> </body> </html>
- Related Articles
- How to wrap first few items in div using jQuery?
- How to wrap and unwrap HTML control with a div dynamically using jQuery?
- How to wrap two adjacent elements in a containing div using jQuery?
- How to scroll to element in horizontal div using jQuery?
- How to wrap an existing element with another one in jQuery?
- How to get the width of a div element using jQuery?
- How to get the height of a div element using jQuery?
- How to create a div element in jQuery?
- How to print div content using jQuery?
- How to duplicate a div using jQuery?
- How to create div dynamically using jQuery?
- How to wrap multiple divs in one with jQuery?
- How to toggle a div visibility using jQuery?
- How to replace innerHTML of a div using jQuery?
- How to load a page in div using jQuery?

Advertisements