This should work:
var img = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('background');
Change . I have a working fiddle that doesn't use querySelector:
var img = window.getComputedStyle(
$(".element")[0], ':before'
).getPropertyValue('background');
Basically, you just want to get the element as the first parameter in getComputedStyle;
But this still does not fix the requirement of IE 8, since it getComputedStyleis not supported there ... However, this question may provide an answer there.
source
share