获取指定元素的当前的样式

/*

* 参数
* obj 要获取样式的元素
* name 要获取的样式名
*/

function getStyle(obj, name) {

    if(window.getComputedStyle) {
        //正常浏览器的方式,具有getComputedStyle()方法
        return getComputedStyle(obj, null)[name];
    } else {
        //IE8的方式,没有getComputedStyle()方法
        return obj.currentStyle[name];
    }

}
原文地址:https://www.cnblogs.com/lufei910/p/12201400.html