Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用.style JavaScript属性添加css框阴影_Javascript_Html_Css - Fatal编程技术网

如何使用.style JavaScript属性添加css框阴影

如何使用.style JavaScript属性添加css框阴影,javascript,html,css,Javascript,Html,Css,我得到了以下JavaScript代码片段: document.getElementById("imgA").style.box-shadow = "0 0 5px #999999"; 框阴影中的连字符导致JavaScript引擎抛出无效的分配异常(在Firefox中)。执行“框影”或“框影”不起作用。有没有一种不使用jquery的.css()方法的好方法?带有-的css属性在Javascript对象的camelCase中表示。所以你不需要连字符-只要写boxShadow document.g

我得到了以下JavaScript代码片段:

document.getElementById("imgA").style.box-shadow = "0 0 5px #999999";

框阴影中的连字符导致JavaScript引擎抛出无效的分配异常(在Firefox中)。执行
“框影”
“框影”
不起作用。有没有一种不使用jquery的
.css()
方法的好方法?

带有
-
的css属性在
Javascript
对象的
camelCase
中表示。所以你不需要连字符
-
只要写
boxShadow

document.getElementById(“shadow”).style[“boxShadow”]=“0 0 5px#99999”
Tushar
您可以使用
style[“boxShadow”]
style.boxShadow

document.getElementById(“foo”).style[“boxShadow”]=“0 0 5px#9999”

12123123
使用
boxShadow

document.getElementById("imgA").style.boxShadow = "0 0 5px #999999";

document.getElementById('redbox').style.boxShadow=“0 0 3px#000”

这应该可以

document.getElementById("demo").style.boxShadow = "0 0 5px #999999";

如果CSS属性名称使用连字符,请将连字符替换为大写字母。因此,对于例如:
text align
将变成
text align
。样式[“框阴影”]
也是可能的。