With this fiddle http://jsfiddle.net/mungbeans/f2ne6/2/
why is the opacity undefined when accessed in js when its defined in the css?
I presume the answer is
Chase is correct, but there's another problem in your code. The style
property only contains styles that were set with the style
attribute of the element, so Chase's solution will only go halfway to fixing your problem. What you want to do is use the getComputedStyle()
function to get the runtime style of your element:
function test(id) {
var listElement = document.getElementById(id);
var titles = listElement.getElementsByTagName("div");
var style = getComputedStyle(titles[0]);
alert( "Opacity: " + style.opacity );
}
See my updated jsfiddle here: http://jsfiddle.net/7vQ4A/1/