-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtable.html
More file actions
70 lines (64 loc) · 1.52 KB
/
table.html
File metadata and controls
70 lines (64 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE HTML>
<html>
<head>
<style>
table {
border-collapse: collapse;
}
td {
border: 3px solid black;
padding: 5px 8px;
}
</style>
</head>
<body>
<table>
<tr>
<td>1:1</td>
<td>2:1</td>
<td>3:1</td>
<td>4:1</td>
<td>5:1</td>
</tr>
<tr>
<td>1:2</td>
<td>2:2</td>
<td>3:2</td>
<td>4:2</td>
<td>5:2</td>
</tr>
<tr>
<td>1:3</td>
<td>2:3</td>
<td>3:3</td>
<td>4:3</td>
<td>5:3</td>
</tr>
<tr>
<td>1:4</td>
<td>2:4</td>
<td>3:4</td>
<td>4:4</td>
<td>5:4</td>
</tr>
<tr>
<td>1:5</td>
<td>2:5</td>
<td>3:5</td>
<td>4:5</td>
<td>5:5</td>
</tr>
</table>
<script>
let table = document.body.firstElementChild;
// table.rows[0].cells[0].style.backgroundColor = 'red'
// table.rows[1].cells[1].style.backgroundColor = 'red'
// table.rows[2].cells[2].style.backgroundColor = 'red'
// table.rows[3].cells[3].style.backgroundColor = 'red'
// table.rows[4].cells[4].style.backgroundColor = 'red'
for (let i = 0; table.rows.length > i; i++) {
table.rows[i].cells[i].style.backgroundColor = 'red';
}
</script>
</body>
</html>