使用原生JS实现获取外部样式和内嵌样式 /** * obj dom对象 * prop 字符串类型的属性名 */ function GetCurrentStyle(obj, prop) { if (obj.currentStyle) { return obj.currentStyle[prop]; } else if (window.getComputedStyle) { return window.getComputedStyle(obj, null)[prop]; } return null; }