123456789101112131415161718192021222324252627282930313233343536373839 |
- var sudoku = [
- [
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- [1, 2, 3, 4, 5, 6, 7, 8, 9]
- ],
- [
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- [1, 2, 3, 4, 5, 6, 7, 8, 9]
- ],
- [
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- [1, 2, 3, 4, 5, 6, 7, 8, 9]
- ],
- ]
- var table, row, cell, i, j;
- table = document.createElement('table');
- table.style.textAlign = 'center';
- table.style.borderCollapse = 'collapse';
- table.style.fontFamily = 'Arial, sans-serif';
- for (i = 1; i < 10; i++) {
- row = document.createElement('tr');
- for (j = 1; j < 10; j++) {
- cell = document.createElement(i == 1 || j == 1 ? 'th' : 'td');
- cell.appendChild(document.createTextNode(i * j));
- cell.style.padding = '5px';
- cell.style.border = '2px solid #ccc';
- cell.style.width = 100 / 9 + '%';
- row.appendChild(cell);
- }
- if (i % 2 == 0) {
- row.style.backgroundColor = '#e2e2e2';
- }
- table.appendChild(row);
- }
- document.body.appendChild(table);
|