Reputation: 96810
This seems to only happen when I use "background" in the parameters of getPropertyValue();
:
var d = document.getElementById('myDiv');
window.getComputedStyle(d).getPropertyValue('background'); // ""
Why does it return an empty string and how can I get this to return the actual background css property?
Upvotes: 3
Views: 5211
Reputation: 19037
According to this page, at least the mozilla browser returns null
when requesting the value of shorthand properties. So it seems have to query the different properties of the background style separately:
window.getComputedStyle(d).getPropertyValue('background-color');
window.getComputedStyle(d).getPropertyValue('background-image');
// etc.
Edit: it looks like it is a known bug
Upvotes: 8