<!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>

 

posted on 2014-11-24 14:21  高尔础础  阅读(315)  评论(0编辑  收藏  举报