I'm currently in the process of generating multiple dynamic HTML tables and assigning a class to each one. Here's an example:
var x = document.createElement("TABLE");
x.className = "table_pos_parts";
//var row = x.insertRow(0);
//var cell = row.insertCell(0);
//var cell1 = row.insertCell(1);
//cell.innerText = "abc";
//cell1.innerText = 123;
var x = document.createElement("TABLE");
x.className = "table_pos_parts";
//var row = x.insertRow(0);
//var cell = row.insertCell(0);
//var cell1 = row.insertCell(1);
//cell.innerText = "def";
//cell1.innerText = 456;
After creating these tables, I tried using console.log(x)
to see them in my console. However, when I attempted to search for them by their classname:
console.log(document.getElementsByClassName("table_pos_parts")); //displays empty
console.log(document.getElementsByClassName("table_pos_parts").length); //outputs 0
The result was that it showed empty. Why is this happening?