My Book

原生js获取样式兼容

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