Let's say a HTML page that has the following CSS:
body { background: url("http://via.placeholder.com/200x200"); width: 200px; height: 200px; }
Why doesn't this:
console.log(document.body.style.backgroundImage); // idem for .style.background
show the URL?
Instead, it shows a blank string.
Notes:
it seems to works for a child
div
, but not for the bodyhere a SO snippet wouldn't help (because this question is specifically for
body
)