Well, I have a function to get the background color of a clicked html element. however, as I set the background color via css, with a class, the object`s background color in x.style.background just returns "";
My code: Html:
<li onclick="setCor(this)" id="vermelho" class="vermelho">Vermelho</li>
The JS function:
function setCor(x){
cor = x.style.backgroundColor;
}
And the .vermelho class:
.vermelho{
background-color: #ff0000;
}
How can I get the css value via JS? I can't use jQuery for it, need to be just JS.