我希望能够单击表格单元格,将其切换到color1,然后在下一次单击时将它切换到color2,然后返回到color1 ...等等。单击时交换表格单元格颜色
function cSwap(cell){
if (cell.style.backgroundColor = "#00000F")
{
cell.style.backgroundColor = "#F00000";
}
else if (cell.style.backgroundColor = "#F00000")
{
cell.style.backgroundColor = "#00000F";
}
}
现在,它只是变成第一种颜色,随后的点击什么都不做。
的每个表的细胞是这样的:
<td classname='t' onclick='cSwap(this);' width='100' height='100' id='nw'><a href="" id="nw"></a></td>
... which'll是CSS一旦我得到一切工作(跑题了)。
抱歉,他们实际上是不同的。我只是碰巧抓住那个。 – xelab 2010-11-08 00:34:31