Сообщение от LinaInverse
|
Таблица может быть любого размера (но квадратная).
|
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
</head>
<body>
<table>
<tr><td>1<td>2<td>3
<tr><td>4<td>5<td>6
<tr><td>7<td>8<td>9
</table>
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
</tr>
</table>
<script>
document.querySelectorAll("table").forEach(table=>{
var trs = table.querySelectorAll("tr");
var tds = table.querySelectorAll("td");
var t = trs.length;
tds.forEach((td,i) => trs[i%t].append(td));
})
</script>
</body>
</html>