javascript操作css属性

内容摘要
复制代码 代码如下:var getstyle = function(elementID,attribute){ obj = document.getElementById(elementID);// 前面是IE后面是html的标准 return obj.currentStyle ? o
文章正文

复制代码 代码如下:

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;


代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!