1. 程式人生 > >兼容獲取元素當前樣式 currentStyle || getComputedStyle

兼容獲取元素當前樣式 currentStyle || getComputedStyle

cti gets get .get dst func style win put

    function getStyle(ele, attr) {
      return ele.currentStyle ? ele.currentStyle[attr] :
        window.getComputedStyle(ele, null)[attr];
    }

兼容獲取元素當前樣式 currentStyle || getComputedStyle