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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:30:56+00:00 2026-06-15T19:30:56+00:00

function load(){ var row=<tr><td><select id=\chooseclass\><option value=\math\>Math</option><option value=\phys\>Physics</option><option value=\lit\>Literature</option><option value=\chem\>Chemistry</option><option value=\bio\>Biology</option><option value=\lang\>Language</option><option value=\proj\>Project</option><option value=\elec\>Elective</option></select></td><td><input id=\choosemods\

  • 0
function load(){
    var row="<tr><td><select id=\"chooseclass\"><option value=\"math\">Math</option><option value=\"phys\">Physics</option><option value=\"lit\">Literature</option><option value=\"chem\">Chemistry</option><option value=\"bio\">Biology</option><option value=\"lang\">Language</option><option value=\"proj\">Project</option><option value=\"elec\">Elective</option></select></td><td><input id=\"choosemods\" type=\"text\" /></td><td><input id=\"choosegrade\" type=\"text\" /></td></tr>";
    var tablebody = document.getElementById("classestable");
    tablebody.innerHTML += "<tbody></tbody>";
    tablebody.getElementsByTagName("tbody").innerHTML = "";
    for(var i=0;i<15;i++){
        tablebody.getElementsByTagName("tbody").innerHTML += row;
    }
}

The code above runs fine except the contents of row does not get added to tbody.

console.log shows that the contents of row is valid html and there are no errors in the console. Why is that not being added?

  • 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-15T19:30:57+00:00Added an answer on June 15, 2026 at 7:30 pm

    getElementsByTagName returns a NodeList and you access it the first node using the index of the node

    I would change the code to the following

    var innerRow = "";
    
    for(var i=0;i<15;i++){
        innerRow += row;
    }
    
    tablebody.getElementsByTagName("tbody")[0].innerHTML = innerRow
    

    this way you only scanning the DOM once not 15 times

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

Sidebar

Related Questions

var value; $(#Grid1).click(function(e) { var row = jQuery(e.target).parent(); value= row.attr(id); }); var onrowclick =
I have a deferred function that binds a mouseenter event: $(window).load(function(e) { var $container
jQuery('ol.productList li.product input[name*=cart.pAsin.]').load().each(function(){ // each function var asinId = jQuery(this).val(); var pUrl = jQuery(this).siblings(a).attr('href');
var studno = $('#studno').val(); $(document).ready(function () { $('.go').click(function () { $('.inup').load('prochat.php', { studno: studno
I'm using the simple jQuery DIV refresh code. var refreshId = setInterval(function() { $('#refreshdash').load('dashboard.php?cache=');
This code: $(#permalink a).click(function(id){ var id = this.getAttribute('href'); $(#newPostContent).load(id, function() { $(#removeTrigger).click(function() { $(#removeThis).hideToggle();
I want to load test.txt with nodejs. var fs = require('fs'); fs.readFile('./test.txt', function (err,
I use, google.load('visualization', '1', {'packages': ['columnchart']}); //google.setOnLoadCallback(drawChart); function drawChart(response) { alert(response.customerlist); var data =
var RowClick = function() { (#Grid).click( var s = $(#Grid).jqGrid('getGridParam', 'selarrrow').toString(); alert(s); $(#showgrid).load('/Inventory/Products/List/' +
//Table select $(#reports-table tr).click( function() { var detail_id = $(this).attr('id'); $(this).addClass(selected); $(this).siblings().removeClass(selected); $('#reports-right').show().load('/members/details/'+detail_id); $('#reports-table').width(680);

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.