Create basic elements like this:
var myTable = document.createElement('table');
var tbody = document.createElement('tbody');
myTable.appendChild(tbody);
then you can go in loop and append cells to tbody like this:
var numberOfRows = 2;
var numberOfCellsInRow = 5;
for (var i = 0; i < numberOfRows; i++) {
var tempRow = document.createElement('tr');
for (var j = 0; j < numberOfCellsInRow; j++) {
var tempCell = document.createElement('td');
tempCell.textContent="myCell";
tempRow.appendChild(tempCell);
}
tbody.appendChild(tempRow);
}
working fiddle
solved How to create the table in javascript [closed]