JavaScript 如何更改 CSS :hover
属性?
例如:
超文本标示语言
<table>
<tr>
<td>Hover 1</td>
<td>Hover 2</td>
</tr>
</table>
CSS
table td:hover {
background:#ff0000;
}
如何使用 JavaScript 将 td :hover
属性修改为(比如说) background:#00ff00
?我知道我可以使用 JavaScript 访问样式背景属性:
document.getElementsByTagName("td").style.background="#00ff00";
但是我不知道 .style
JavaScript 是否与 :hover
等价。