呵呵,如果是IE,和函数可以用的,这样编不是太好EXCU

解决方案 »

  1.   

    <style type="text/css">
    .red{background-color:#FF0000; width:200px; height:200px;}
    .blue{background-color:#0000FF; width:200px; height:200px;}
    </style>
      <script language="javascript"> 
      function T(){
      if(document.getElementById("test").className == "red"){
       document.getElementById("test").className = "blue";
      }else{
      document.getElementById("test").className = "red"
      }
      }
      </script> 
    <div id="test" class="red"></div>
    <a href="#" onclick="T();">改变背景</a>