您只能在计算后才能获取通过类设置的值.
var oElm = document.getElementById ( "myStyle" ); var strValue = ""; if(document.defaultView && document.defaultView.getComputedStyle) { strValue = document.defaultView.getComputedStyle(oElm, null).getPropertyValue("-moz-opacity"); } else if(oElm.currentStyle) // For IE { strValue = oElm.currentStyle["opacity"]; } alert ( strValue );