<!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>