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

  • SEARCH
  • Home
  • 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 8581707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:07:03+00:00 2026-06-11T21:07:03+00:00

Please check this example: http://jsfiddle.net/lulu2792/a9LZd/ I use innerHTML to set a table row content

  • 0

Please check this example: http://jsfiddle.net/lulu2792/a9LZd/

I use innerHTML to set a table row content (including cell contents), I run well on Firefox & Chrome. However, It has a bug on IE7 (also on IE9 Compatibility Mode). The table HTML result is:

<TABLE id=table1>
 <TBODY>
  <TR>
   <TD>
    Test
   </TD>
  </TR>
  <TR>
   ABC
   </TD>
  </TR>
 </TBODY>
</TABLE>

Please focus on the 2nd row, it has a bug. I don’t understand why innerHTML cause this bug on IE7. How to correct this problem?

And I also have a question: if I don’t use tbody tag inside a table element like this:

var html = "<table id='table1'><tr><td>Test</td></tr></table>";

browser still renders this tag.

Please help me to answer two above questions.

  • 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-11T21:07:04+00:00Added an answer on June 11, 2026 at 9:07 pm

    You can’t use the innerHTML property to write parts of a table in IE, you must use DOM methods. innerHTML can be used to write an entire table, or the contents of a cell.

    There is an example on MSDN: Building Tables Dynamically.

    There is also an example on MDN: Using the DOM Table Interface

    In the code you posted elsewhere (much better to post it here):

    // create table
    var html = "<table id='table1'><tbody><tr><td>Test</td></tr></tbody></table>";
    document.getElementById('div1').innerHTML = html;
    

    That works fine because it creates an entire table.

    // append a row into table
    var tr = document.createElement('tr');
    var td = document.createElement('td');
    td.innerHTML = 'ABC';
    tr.appendChild(td);
    var s = tr.innerHTML;
    

    The above works fine in all browsers.

    tr.innerHTML = s;
    

    Ooops, can only assign to the innerHTML of a cell (td or th), not any other part of a table.

    tr.innerHTML = '<td>' + 'ABC' + '</td>';
    

    Same again.

    var tbody = document.getElementById('table1').getElementsByTagName('tbody')[0];
    

    You can use the tBodies property to simplify that:

    var tbody = document.getElementById('table1').tBodies[0];
    tbody.appendChild(tr);
    

    That would work fine if you hadn’t messed with the innerHTML of the tr.

    Note that you could also do:

    var tbody = document.getElementById('table1').tBodies[0];
    var row = tbody.insertRow(-1);
    var cell = row.insertCell(-1);
    cell.innerHTML = 'whatever';
    

    And you’re done. You can also clone an entire row then modify the cell contents with innerHTML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off please see my example in JSfidle: http://jsfiddle.net/WMxKk/1/ You can see when you
Please check this: http://img62.imageshack.us/img62/3598/ieff.png why is it more height than in FF.. i want
http://ano-mag.com/black-foil/ please check this url - click the Order Now button on the left
I am learning php and read this example in this http://www.php.net/manual/en/language.types.boolean.php tutorial, I want
please check this example which I am trying to achieve.. the title is automatically
Hello please check this site you 'll see that next content will be loaded
Please check this code out it compiles and runs absolutely fine.. The question is
Can you guys please check this code, it is MVC3 Razor <p><strong><u>Skills:</u></strong> @foreach (var
First of, please check this picture: As you can see, left from Today and
I have created a DeclarativeServiceLibrary using VS2010 beta 2, Please check this image of

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.