window.getComputedStyle和elem.currentStyle兼容式写法

export function getStyle(el,attr){
    if(el.currentStyle){
        //IE,OPER
        return el.currentStyle[attr];
    }else{
        //chrome、safari、FireFox
        return window.getComputedStyle(el)[attr];
    }
}

猜你喜欢

转载自blog.csdn.net/qq_38652871/article/details/89139614
今日推荐