Javascript 为什么getPropertyValue返回空字符串而不是元素';s风格的酒店?

Javascript 为什么getPropertyValue返回空字符串而不是元素';s风格的酒店?,javascript,css,Javascript,Css,这似乎只有在getPropertyValue()的参数中使用“background”时才会发生: 为什么它会返回一个空字符串?我如何才能让它返回实际的后台css属性?根据,至少mozilla浏览器在请求值时会返回null。因此,它似乎必须分别查询背景样式的不同属性: window.getComputedStyle(d).getPropertyValue('background-color'); window.getComputedStyle(d).getPropertyValue('backgr

这似乎只有在
getPropertyValue()的参数中使用“background”时才会发生

为什么它会返回一个空字符串?我如何才能让它返回实际的后台css属性?

根据,至少mozilla浏览器在请求值时会返回
null
。因此,它似乎必须分别查询背景样式的不同属性:

window.getComputedStyle(d).getPropertyValue('background-color');
window.getComputedStyle(d).getPropertyValue('background-image');
// etc.

编辑:它看起来像是一个

这种行为在IE11和FF 36.01中仍然存在,但Chrome 40.0.2214.115按预期工作,并返回组合的速记样式。
window.getComputedStyle(d).getPropertyValue('background-color');
window.getComputedStyle(d).getPropertyValue('background-image');
// etc.