@Sebastian Heyn 请检查以下代码。我希望你也有同样的期望。
table:hover {
background-color: #FFEB3B;
color: red;
}
<table>
<tr>
<th>Header</th>
<th>Header</th>
</tr>
<tr><td>Somecontent</td>
<td>Somecontent</td>
</tr>
</table>
为什么要结合使用内联 JS 和 CSS?把这些东西放在你的样式表中......
table:hover {
background: red;
}
试试我的代码。希望它可以帮助你。
.sample {
border:1px;
}
.sample th{
background-color:red;
}
.sample th:hover{
background-color:blue;
}
<table class="sample" border=1>
<tr><th>Header</th></tr>
<tr><td>Somecontent</td></tr>
</table>
我不是专家,但也许你应该制作表 ID 并使用一些 jquery 函数。
th:hover,td:hover {
background-color: #FFEB3B;
color: red;
}
<table>
<tr>
<th>Header</th>
<th>Header</th>
</tr>
<tr><td>Somecontent</td>
<td>Somecontent</td>
</tr>
</table>