0

How do I get the value of a CSS attribute with JS?

I am trying this: var elemento = document.getElementById("circulo1"); var posicion_elemento = elemento.style.left; alert(posicion_elemento); but it doesn't work. It is showing me nothing, just blank.

18th Mar 2017, 7:13 PM
Elvis Briceño
Elvis Briceño - avatar
1 ответ
0
<div class='lll' style="color:red"></div> var t = document.getElementsByClassName('lll'); console.log(getComputedStyle(t[0]).color);
18th Mar 2017, 7:35 PM
Ihor