I am trying to get the value of "display" through JS sorted by Classes. My code is:
var x = document.getElementsByClassName("codeContainer");
alert(x[0].style.display);
The thing is that the alert box is just empty. The call
alert(x.length);
works great and returns "4". What am I doing wrong? Thanks very much!
Problem is, if the element is formatted by external css instead of inline css using style attribute, you are bound to get blank value.
With inline css:
You need to get the computed style for the same, getStyle() reference.