标签:
var obj=document.getElementById(‘obj‘);
function getAttr(node,attr) {
//make attr to example as marginLeft;
//inline style
if(node.style[attr]){
return node.style[attr];
}
//w3c getComputedStyle(also can get <style></style> in html)
else if(document.defaultView && document.defaultView.getComputedStyle){
return document.defaultView.getComputedStyle(node,null)[attr];
}
//IE CurrentStyle(also can get <style></style> in html)
else if(node.currentStyle){
return node.currentStyle[attr];
}
else {
return null;
}
}
alert(getAttr(obj,"color"));
标签:
原文地址:http://www.cnblogs.com/wz0107/p/4457329.html