码迷,mamicode.com
首页 > 其他好文 > 详细

Computed Styles

时间:2015-06-06 17:46:16      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:

 

The style object offers no information about the styles that have cascaded from style sheets and affect the element. DOM Level 2 provide a method called getComputedStyle(). This method accepts two arguments: the element to get the computed style for and a pseudo-element string (such as ":after"). The second argument can be null if no pseudo-element information is necessary.  IE doesn‘t support getComputedStyle(), though it has a similar concept. Every element that has a style property also has a currentStyle property.

1 function getStyle(obj, name) {
2     if (obj.currentStyle) { 
3         return obj.currentStyle[name];
4     } else {
5         return getComputedStyle(obj, null)[name];
6     }
7 }    

 

Computed Styles

标签:

原文地址:http://www.cnblogs.com/linxd/p/4556833.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!