js之: 获取css属性值

var time = document.getElementById('time')
         var getStyle = function(t, n) {
                 var o = t.currentStyle ? t.currentStyle : window.getComputedStyle(t, null);
                 return o[o.getPropertyValue ? "getPropertyValue" : "getAttribute"](n)
             }
         console.log(getStyle(time,'width'))

 

posted @ 2018-07-27 15:25  二月花开  阅读(267)  评论(0)    收藏  举报