我想更改表格中一个特定单元格的颜色:为什么以下操作不起作用?
document.getElementById('myTable').rows[i].cells[j].bgColor="#mybgColor";
Run Code Online (Sandbox Code Playgroud)
其中i和j肯定是在行和单元格范围内的一些整数。我不需要任何花哨的 JQuery 左右,只需要这个简单的命令。
CSS 样式将覆盖bgColor已弃用的属性。使用.style.backgroundColor代替.bgColor:
document.getElementById('myTable').rows[i].cells[j].style.backgroundColor = "#003366";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7754 次 |
| 最近记录: |