这个 Get the rendered style of an element 是2006年4月的24发的,但我今天才看到。

为了拿到元素的当前样式

ie 用 currentStyle 和 runtimeStyle

ff 用 getComputedStyle

opera 似乎是直接 style 和 getComputedStyle 都可以(记不清楚了,谅解)

以前都是自己写,再说公司的破项目仍然都在 ie 6 下跑,因此倒还没感到痛苦。

函数定义

显示更多

调用

显示更多

唯一缺点在于 ie 5,需要加 try catch

下载 getStyle.js