如何用表格的OnClick事件来改变表格的CSS

如题

比如想实现鼠标移动过某单元格时背景色为红色

而鼠标点击过该单元格时背景色变为黑色

要怎么实现呢?

实验证明<td onclick="this.class='asgasg'"></td>和<td onclick="this.style.background-color='#000000'"></td>不能.

this.class改成this.className
this.style.background-color改成this.style.backgroundColor
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答