JSFiddle - React, Tailwind, and code Playground
CSS
table {
margin: 0 auto;
margin-bottom: 30px;
border: 1px solid #ffffff;
border-collapse: collapse;
}
td {
padding-left: 20px;
text-align: center;
}
JavaScript
//Создание динамической таблицы
//с использованием циклов for, do wile, while
var mtable = document.createElement('table');
var mtbody = document.createElement('tbody');
var number = 1;
var number2 = 65;
$('body').append(mtable);
$(mtable).append(mtbody);
//--------------------------------------------------for
var mtd;
for (var i = 1; i <= 7; i++) {
var mtr = document.createElement('tr');
$(mtbody).append(mtr);
// table-left
$(mtr).append(mtd = document.createElement('td'));
$(mtd).append(number++);
$(mtr).append(mtd = document.createElement('td'));
mtd.textContent = "Table -1 (for)";
//table-right
$(mtr).append(mtd = document.createElement('td'));
$(mtd).append(--number2);
}
mtable.setAttribute("border", "1");
mtable.setAttribute("width", "400px");
mtable.setAttribute("height", "100px");
//--------------------------------------------------do wile
var mtable = document.createElement('table');
var mtbody = document.createElement('tbody');
$('body').append(mtable);
$(mtable).append(mtbody);
var i = 0;
do {
i++
var mtr = document.createElement('tr');
$(mtbody).append(mtr);
// table-left;
$(mtr).append(mtd = document.createElement('td'));
$(mtd).append(number++);
$(mtr).append(mtd = document.createElement('td'));
mtd.textContent = "Table -2 (do while)";
//table-right
var mtd4;
$(mtr).append(mtd = document.createElement('td'));
$(mtd).append(--number2);
} while (i < 7)
mtable.setAttribute("border", "1");
mtable.setAttribute("width", "400px");
mtable.setAttribute("height", "100px");
//--------------------------------------------------while
var mtable = document.createElement('table');
var mtbody = document.createElement('tbody');
$('body').append(mtable);
$(mtable).append(mtbody);
var i = 0;
while (i < 7) {
i++
var mtr = document.createElement('tr');
$(mtbody).append(mtr);
// table-left;
$(mtr).append(mtd = document.createElement('td'));
...