cssText 批量为元素赋属性值
结果
[img]http://dl2.iteye.com/upload/attachment/0108/3536/44fab231-3d00-3678-9f29-03fa62a26202.png[/img]
注意:更新已存在的属性值 没有把csstext中不存在的去掉
css
#div0{display: inline-block; width: 300px; height: 200px;text-align: center;color:red}
html
<div id="div0">
<div><p>fdfdfff</p></div>
<span>dfdf</span>
</div>
js
var a=document.getElementById('div0');
a.style.cssText="width:200px;height:70px;display:bolck;";
结果
[img]http://dl2.iteye.com/upload/attachment/0108/3536/44fab231-3d00-3678-9f29-03fa62a26202.png[/img]
注意:更新已存在的属性值 没有把csstext中不存在的去掉