【封装函数】原生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]; }