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

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

原文地址:https://www.cnblogs.com/NatChen/p/6214810.html