这是怎么回事:
onmouseover="imageOn(bg-index);" onmouseout="imageOff(bg-index);"
这是我在 ID 为 table-title
的 table
上的两个属性。这些函数是远程 JS 文件的一部分:
if (name == 'bg-index') { document.getElementById("table-title").style.backgroundImage = "url('images/bg-index.png')"; }
...与 imageOff
是同一件事,但图像不同。这是行不通的;我做错了什么?
最佳答案
onmouseover="imageOn('bg-index');" onmouseout="imageOff('bg-index');"
尝试将函数变量作为字符串。
关于JavaScript - 图像样式更改无法正常运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17534562/