Set up a table. When the mouse moves to a certain row, the color changes. When the mouse leaves, the color changes to the original color. Each line requires two mouse events:
1. Mouse override: onMouseOver
2. Mouse out: onMouseOut
At the same time, these two events need to call the event function:
1. To set the color of the row:
resetColor(row)
2. Implement the change of row color:
changeColor(row)
Implementation code:
变色表格示例
学校 | 专业 | 人数 |
---|---|---|
北大 | 法律 | 2000 |
清华 | 计算机 | 5000 |
人大 | 经济 | 6000 |
The above is the detailed content of How to use JavaScript+CSS+DIV to change the color of the table. For more information, please follow other related articles on the PHP Chinese website!