一、元素节点内联样式
1、样式设置
oDiv.style.width = “300px”
2、获取,因为一般都是获取样式表中的,而不是行间
function getStyle(obj,attr) {
return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj,false)[attr]
}
//如果是行间,直接odiv.style,会获取到一个CSSStyleDeclaration对象。odiv.style.width就获取到了宽,也可以设置。
3、cssText属性。
oDiv.style.cssText = 'background-color:red;border:1px solid #000;height:100px;';
4、setAttribute、getAttribute、removeAttribute;
oDiv.setAtrribute('style','background-color:red;border:1px solid #000')
oDiv.getAttribute('width')
oDiv.removeAttribute('width')