【封装函数】原生js 获取行内外联样式-兼容IE

var dom=document.getElementsByTagName("div")[0];

console.log(getStyle(dom,"padding-top"));

 

function getStyle(ele,attr){
  if(window.getComputedStyle){
    return window.getComputedStyle(ele,null)[attr];
  }
  return ele.currentStyle[attr];
}
原文地址:https://www.cnblogs.com/ivan5277/p/9765097.html