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?
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?
Share Improve this question asked Feb 20, 2012 at 16:11 David GDavid G 96.9k41 gold badges172 silver badges258 bronze badges 1- This behaviour persists in IE11 and FF 36.01 but Chrome 40.0.2214.115 works as expected and returns the assembled short-hand style. – Cool Blue Commented Mar 14, 2015 at 3:37
1 Answer
Reset to default 8According 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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742360698a4429333.html
评论列表(0条)