Я хотел бы сказать, что это не правильно с точки зрения семантики;Однако вы можете установить правило role=button
в своем html.
function navigateTo(url) {
window.location.href(url);
}
document.querySelector('#row-1').addEventListener('click', function() { navigateTo('http://www.google.com/') });
table {
border-collapse: collapse;
}
tr {
border: 1px solid black;
cursor: pointer;
}
tr:hover {
background: rgba(255,0,0,0.3);
}
<table>
<tr id='row-1' role='button'>
<td>Item 1</td>
<td>Item 2</td>
<td>Item 3</td>
<td>Item 4</td>
<td>Item 5</td>
<td>Item 6</td>
</tr>
<tr id='row-2' role='button'>
<td>Item 7</td>
<td>Item 8</td>
<td>Item 9</td>
<td>Item 10</td>
<td>Item 11</td>
<td>Item 12</td>
</tr>
</table>