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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:12+00:00 2026-05-26T15:09:12+00:00

The function simply injects new rows into an empty table when the function is

  • 0

The function simply injects new rows into an empty table when the function is called.

it would seem that since the <td> class gets assigned properly, that the <tr> would also get assigned… but it doesn’t!

var newRow = document.createElement("tr");

for (data in dataArray)
{
    var newName = document.createElement("td"); 

    newName.className = classNames[data];
    newName.innerHTML = dataArray[data];
    newRow.appendChild(newName);
    counter++;
}
document.getElementById("capturedData").appendChild(newRow);
var newRow2 = document.createElement("tr");
newRow2.class = "hiddenRow";

for (data in dataArray)
{
    var newData = document.createElement("td");
    var newDataField = document.createElement("input");

    newDataField.type = "hidden";
    newDataField.name = "name" + data;
    newDataField.value = dataArray[data];

    newData.class = classNames[data];
    newData.value = dataArray[data];

    newData.appendChild(newDataField);      
    newRow2.appendChild(newData);   
}

which is really weird. All the newly added <td> elements have their classes assigned and they show up in the DOM. But the <tr> elements don’t accept the class assignment and in the DOM they have no class.

Why is this? I’ve read about the purported asynchronicity of script execution, but surely this can’t be the case, it would defeat the purpose, no?

  • 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-26T15:09:12+00:00Added an answer on May 26, 2026 at 3:09 pm

    DOM elements have no property class, because it is a reserved keyword. You are looking for className:

    newRow2.className = "hiddenRow";
    

    Same for the cell (newData). It works for your other cell because you are using className already:

    newName.className = classNames[data];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I needed a function that simply checks if a string can be converted to
Is there a basic function call in MFC that simply plays the input error
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
What function in VB.NET simply takes a string parameter and runs a command? It
I simply want to fill-up cells in my spreadsheet from a VBA function. By
Simply Asking, Is there any function available in mysql to split single row elements
I keep getting dialogDiv.dialog is not a function. I'm simply trying to invoke the
I have a simple function that I want to call in the code behind
I'm looking to build a cross-site bookmarklet that gets a highlighted word, passes it
My website has an opt-in member directory. Currently, the error checking function simply looks

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.