首页 > 代码库 > json批量设置DIV属性

json批量设置DIV属性

<!doctype html><html><head><meta charset="utf-8"><title>批量设置</title><style>#div1 { width:200px; height:200px; border:5px solid red; }</style><script>window.onload=function (){    var oDiv=document.getElementById(div1);        setStyle(oDiv,{        width:500px,        height:500px,        background:red,        border:20px solid blue        });};function setStyle(obj,json){    for( var i in json)    {        obj.style[i]=json[i];    }}</script></head><body>    <div id="div1"></div></body></html>

 

json批量设置DIV属性