首页 > 语言 > JavaScript > 正文

javascript操作css属性

2024-05-06 14:31:17
字体:
来源:转载
供稿:网友

代码如下:
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;

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选