Consider an HTML document with the given CSS:
body { background: url("http://via.placeholder.com/200x200"); width: 200px; height: 200px; }
Why does the following code not display the background image URL when executed:
console.log(document.body.style.backgroundImage); // same for .style.background
Instead of the URL, an empty string is returned.
Additional Information:
The code seems to work for a child
div
, but not for the body element.A Stack Overflow snippet is not effective in this case as the question pertains specifically to the
body
element.