原生js获取元素属性值方法
function getStyle(obj,attr){ return obj.currentStyle? obj.currentStyle[attr]:getComputedStyle(obj)[attr] }
使用示例:
var oDiv=document.getElementById("test");
alert(getStyle(oDiv,"top"));
Live and learn!
function getStyle(obj,attr){ return obj.currentStyle? obj.currentStyle[attr]:getComputedStyle(obj)[attr] }
使用示例:
var oDiv=document.getElementById("test");
alert(getStyle(oDiv,"top"));
Live and learn!