Answers for "using while loop to create table rows js"

0

using while loop to create table rows js

function newNode(node, text, styles) {
  node.innerHTML = text;
  node.className = styles;
  return node;
}

var fragment = document.createDocumentFragment(),
  container = document.getElementById("container");

for(var i = 1; i <= 10; i++) {
  var tr = document.createElement("tr");
  var td = newNode(document.createElement("td"), i, "cell");
  tr.appendChild(td);
  fragment.appendChild(tr);
}

container.appendChild(fragment);
Posted by: Guest on May-15-2021

Code answers related to "using while loop to create table rows js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language