DOCTYPE HTML html head meta charset utf-8 style table font-size 20px h

 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
71
72
73
74
75
76
77
78
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<style>
table {
font-size: 20px;
height: 30%;
width: 30%;
margin: 10px;
text-align: center;
}
td, th {
border: 1px solid black;
}
</style>
</head>
<body>
<table id="grid">
<thead>
<tr>
<th data-type="number">Возраст</th>
<th data-type="string">Имя</th>
</tr>
</thead>
<tbody>
<tr>
<td>5</td>
<td>Вася</td>
</tr>
<tr>
<td>10</td>
<td>Петя</td>
</tr>
<tr>
<td>15</td>
<td>Джон</td>
</tr>
<tr>
<td>20</td>
<td>Джорж</td>
</tr>
<tr>
<td>25</td>
<td>Джотаро</td>
</tr>
<tr>
<td>30</td>
<td>Жоске</td>
</tr>
</tbody>
</table>
<script>
let target = document.querySelector('th');
target.onmouseover = target.onmouseout = handler;
console.log(target);
function handler(event) {
if (event.type == 'mouseover') {
event.target.style = 'background-color: yellow';
console.log('mouseover');
}
if (event.type == 'mouseout') {
event.target.style = 'background-color: white'
console.log('mouseout');
}
}
</script>
</body>
</html>