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 6188385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:13:20+00:00 2026-05-24T02:13:20+00:00

I am learning this stuff and trying to understand it, so am using this

  • 0

I am learning this stuff and trying to understand it, so am using this instead of innerhtml.

My code:

  <script>
function load() {
"use strict";

var t  = document.createElement("table"),
    tb = document.createElement("tbody"),
    tr = document.createElement("tr"),
    td = document.createElement("td");

    var b = document.createElement("b");
b.appendChild(document.createTextNode(" name!"));
td.appendChild(document.createTextNode("Hello"));
td.appendChild(b); 

    t.style.width = "100%";
    t.style.borderCollapse = 'collapse';
    t.border=1;

    // note the reverse order of adding child        
    tr.appendChild(td);
    tb.appendChild(tr);
    t.appendChild(tb);

   // more code to populate table rows and cells
   document.getElementById("theBlah").appendChild(t);
alert(t.innerHTML);
   }
</script>
 </head>

 <body  onload="load()">

problem is , onload() does not display the <table> tag, it displays from <tbody> instead… any idea why?

And finally, in this code:

var t  = document.createElement("table"),

 tb = document.createElement("tbody"),
 tr = document.createElement("tr"),
 td = document.createElement("td");

even though I am using the Var keyword just for t, and not for the others, why is it not complaining even though “use strict” is on? In fact if I add a “var” in front of “tb, “tr”, “td” then it throws an error…
Thanks!

  • 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-05-24T02:13:21+00:00Added an answer on May 24, 2026 at 2:13 am

    1) innerHTML is just that. It’s inner. It doesn’t contain the HTML of the element itself, but all the html that is within that element. There is a property called outerHTML too, but it’s not included in Firefox. The only cross browser way to get outerHTML is to wrap the node in a new parent node and grab that nodes innerHTML. You can’t just grab the current parent’s innerHTML (You have to make a new parent) unless you’re sure the element has no siblings, because if you do the siblings will included.

    2) You are using commas to separate your variable decorations. That is the same as using semi-colons and putting var on each line.

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

Sidebar

Related Questions

I'm learning jQuery by trying to understand other people's code. I ran into this:
Learning my way through this stuff and could use some help. I'm trying to
I'm learning this wpf stuff and trying to get my head around validation of
Just learning this stuff, so bear with any ignorance... In what I'm trying to
I'm working on a project in C#, it's about E-learning.This project should use plug-ins
I'm learning by reading this tutorial: Link Here's the code: <?php require_once 'Zend/Loader.php'; class
I am learning Google's new language Go . I am just trying stuff out
I am trying to generate some xml with this php code here... I am
I've just started learning how to use pygame yesterday. I was read this one
I'm learning this right now so the questions might be a little juvenile. Here's

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.