javascript操作css属性


复制代码 代码如下:

var getstyle = function(elementID,attribute){
 obj = document.getElementById(elementID);
// 前面是IE后面是html的标准
 return obj.currentStyle ? obj.currentStyle[attribute] : document.defaultView.getComputedStyle(obj, false)[attribute];
}

还有一种可以获取写在html中的style属性的

复制代码 代码如下:

document.getElementById("elementId").style.paddingLeft;


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3