解决方案 »

  1.   

    样式表设置如下:
    <style>
    body{font-size:12px; padding-top:32px;}
    div{width:600px; text-align:center; margin:0px auto; height:42px;}
    .c1{border:1px solid blue;}
    .c2{border:1px solid #ff0000;}
    </style>js代码如下:
    <script>
    function get1()
    {
     document.getElementById("div1").className="div c1";
    }
    function get2()
    {
     document.getElementById("div1").className="div c2";
    }
    </script>网页内容如下:
    <div id="div1"></div><br />
    <div><input type="button" value="边框蓝色" onclick="get1()" /> &nbsp; <input type="button" name="button" id="button" value="边框红色" onclick="get2()" /></div>
      

  2.   

    window.onload=initDIV;
    function initDIV() {
    var allBody=document.getElementById("wholeBody");//可以直接写document.body
    function f(){allBody.style.background=(this.currentStyle||document.defaultView.getComputedStyle(this,null)).background;}
    document.getElementById("cID").onclick = f;
    document.getElementById("dID").onclick = f;
    document.getElementById("eID").onclick = f;
    }