很多人在用JS控制CSS样式的时候肯定有人碰到过不知道怎么修改它的样式。而且在JS中与CSS中所写的方法有所不同。不同之处就不在此说明大家可以去看JS可以控制样式的名称写法。style中的cssText
使用方法如下:
document.getElementById("sd").style.cssText="width:100p;background:#f60";
这样使用起来是不是很方便呢,呵呵!
实例如下:
<div id="sd" style="width:200px">afdaf</div>
<script>document.getElementById("sd").style.cssText="width:100px;background:#f60";</script>