JSFiddle - React, Tailwind, and code Playground
by chridam
HTML
<div id="div1"></div>
JavaScript
function drawTable() {
// get the reference for the body
var div1 = document.getElementById('div1');
div1.innerHTML = "";
// creates a <table> element
var tbl = document.createElement("table");
var totalRows = 3;
// creating rows
for (var r = 0; r < totalRows; r++) {
var row = document.createElement("tr");
var cellsInRow = 4;
var max = 10, min = 1;
// create cells in row
for (var c = 0; c < cellsInRow; c++) {
var cell = document.createElement("td");
getRandom = Math.floor(Math.random() * (max - min + 1)) + min;
var cellText = document.createTextNode(Math.floor(Math.random() * (max - min + 1)) + min);
cell.appendChild(cellText);
row.appendChild(cell);
}
tbl.appendChild(row); // add the row to the end of the table body
}
div1.appendChild(tbl);
}
drawTable();