Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7956279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:56:41+00:00 2026-06-04T03:56:41+00:00

How do i Wrap a table in a div? I’m using $(table).each(function() to locate

  • 0

How do i Wrap a table in a div?

I’m using $(“table”).each(function() to locate the tables i then need to enclose it in a div this is a snippet of my code tNum is just a sequential number to give the div a unique id

     var strToAppend = "<div>Blah Blah</div>
     $(this).wrap(function(){
       return "<div class = 'tabDiv'  id='tabDiv' + tNum +">" + $(this) + "</div>" +   strToAppend;
   });

this crates [object Object] before the table but no strToAppend

[object Object] is seen in the web page
What am i doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:56:42+00:00Added an answer on June 4, 2026 at 3:56 am

    It seems that your aims could be achieved with the following, which perhaps looks more complex than your append a string, but is still quite simple:

    $('table').each(
        function(i){
            var that = $(this),
                tabDiv = $('<div />',
                           {'class' : 'tabDiv',
                            'id' : 'tabDiv' + i}),
                newDiv = $('<div />').text('some text in a div element');
            that.wrap(tabDiv);
            that.parent().append(newDiv);
        });
    

    JS Fiddle demo.

    References:

    • each().
    • parent().
    • text().
    • wrap().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't quite wrap my head around this one... A table like the one
I got stuck with this problem. I wrap two tables inside of a h:form.
I am attempting to wrap some C code in Python using Pyrex. I've run
$(.wrap table tr:first).addClass(tr-top); it works for the first table, but i have many tables
print '<div id=wrap>'; print <table width=\100%\ border=\0\ align=\center\ cellpadding=\3\ cellspacing=\3\>; for($i=0; $i<count($news_comments); $i++) {
I need a div with a border to wrap around arbitrarily sized fixed-width content
In ASP.NET Gridviews generate a table which generates a parent div container. This can
Here is my html code: <div id=notes> <table class=noborder> <tr><th class=noborder><span>notes</span></th></tr> <tr><td> <p id=notes_p>
This is the HTML I am parsing: <div class=audio id=audio59779184_153635497_-28469067_16663> <table width=100% cellspacing=0 cellpadding=0><tbody><tr>
I have some code dynamically created by Sigma, which looks like this: <div id=myGrid1_headDiv

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.