javascript中封装获取样式属性值的兼容方法

function getStyle(obj, attr) {
        if (window.getComputedStyle) {
            return window.getComputedStyle(obj, null)[attr];
        } else {
            return obj.currentStyle[attr];
        }
    }

 

posted @ 2016-09-21 15:05  萧诺  阅读(109)  评论(0编辑  收藏  举报