NatChen

Once you have chosen the road of life, you have to be brave enough to go to the end and never look back.

前端入门_获取对象内联样式属性值的兼容性封装

function getStyle(obj, style) {
               if (window.getComputedStyle) {
                                 //chrome, firefox, ie9以上版本浏览器的支持写法
                         return window.getComputedStyle(obj, null)[style];
                  } else {
                                //所有ie版本的支持写法, 但chrome和firefox不支持
                         return obj.currentStyle[style];
                 }
}

posted @ 2016-12-23 14:58  NatChen  阅读(231)  评论(0编辑  收藏  举报