Could anyone tell me why document.body.style.backgroundColor
doesn't work with external CSS style sheet?
I mean: when I have
body
{
background-color: red;
}
in my css style sheet javascript alert alert(document.body.style.backgroundColor);
shows empty string.
Working example here.
but when I have
<body style="background-color: red;"></body>
it shows (as it should) "red". Example here.
I would appreciate a good explanation and even more an answer how to fix the first example.