js批量设置style属性
JS中给一个html元素设置css属性,可以通过style属性来操作
var head= document.getElementById("head");head.style.width = "200px";head.style.height = "70px";head.style.display = "block"; function setStyle(obj,css){ for(var atr in css) obj.style[atr] = css[atr];}var head= document.getElementById("head");setStyle(head,{width:"200px",height:"70px",display:"block"}) dom.setAttribute("style","width:10px;height:10px;border:solid 1px red;") var head= document.getElementById("head");head.style.cssText="width:200px;height:70px;display:bolck";