Dark_Delphin,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
td {
text-align: center;
border: solid 1px #0000FF;
}
table {
border-collapse: collapse;
border: 1px solid #0000FF;
width: 300px;
}
</style>
</head>
<body>
<table></table>
<script>
Array.prototype.shuffle = function (min, max) {
min = min || 0;
max = ++max || this.length;
var len = max - min;
max = len - this.length;
this.length = len;
for (var a = this.length - 1; 0 <= a; a--) {
if (a < max) break;
var b = Math.floor(Math.random() * a),
c = void 0 === this[b] ? (b + min) : this[b];
this[b] = void 0 === this[a] ? (a + min) : this[a];
this[a] = c
}
this.reverse();
this.length -= max;
return this
};
var arr = Array(16).shuffle(1, 5000);
var table = document.querySelector("table");
var length = 4, tr;
arr.forEach(function (number, indx) {
if (indx % length == 0) tr = table.insertRow(indx / length | 0);
var td = tr.insertCell(indx % length);
td.innerHTML = number
});
</script>
</body>
</html>
|