这是我的问题:
var mycss = window.getComputedStyle(myelement);
返回一个 CSSStyleDeclaration 对象:
CSSStyleDeclaration {0: "animation-delay",..., backgroundColor: "rgb(0, 0, 0)",...}
然后,我想获取背景颜色,但是
mycss.getPropertyValue("backgroundColor");
返回空字符串 ""
!
为什么??
最佳答案
代替
mycss.getPropertyValue("backgroundColor");
使用
mycss.getPropertyValue('background-color')
这对我有用。
关于javascript - getPropertyValue ("backgroundColor") 返回一个空字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48306795/