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
For two reasons:
getElementById(). Thus, you need to subscript the resulting NodeList to get the required DOM element;style property of the element, you'll only get the inline styles, not the ones that you assign through a CSS class.To get the computed styles, you could use window.getComputedStyle(), which will give you the final used values of all the CSS properties of the element:
alert(window.getComputedStyle(title).opacity);
DEMO.
Unfortunately, getComputedStyle is not available in IE < 9, but you can easily find a polyfill, such as this one.