for(var i=0;i<document.getElementsByTagName("A");i++)
{
document.getElementsByTagName("A")[i].className="oldClass"
}
event.srcElement.className="newclass"

解决方案 »

  1.   

    <style>
    a{color:green;background:yellow}
    a.a2{color:red;background:lightblue}
    </style>
    <script>
    function changeclr(obj)
    {
      for(i=0;i<document.all.tags("a").length;i++)
      document.all.tags("a")[i].className="";
      obj.className="a2";
    }
    function change(obj)
    {
    obj.style.color="red";
    }
    </script>
    <a onclick=changeclr(this)>123</a>
    <a onclick=changeclr(this)>456</a> 
    <a onclick=changeclr(this)>789</a>
      

  2.   

    如果它本身已经在一个onclick事件例如:
    function goto2(){
        ifram.document.URL="/jsp/user/student_trust_manage.jsp";
    } <TR>
              <TD class=nav-sub align=right width=130><A 
                href="#" onclick="goto2()"><font size="2">管理设置</font></A></TD>
     </TR>
    该怎么办?请给以提示谢谢!!
      

  3.   

    <style>
    a{color:green;background:yellow}
    a.a2{color:red;background:lightblue}
    </style>
    <script>
    function changeclr(obj)
    {
      for(i=0;i<document.all.tags("a").length;i++)
      document.all.tags("a")[i].className="";
      obj.className="a2";
    }
    function goto2(){
        ifram.document.URL="/jsp/user/student_trust_manage.jsp";
    }
    </script>
    <a onclick=changeclr(this);goto2()>123</a>
    <a onclick=changeclr(this);goto2()>456</a> 
    <a onclick=changeclr(this);goto2()>789</a>
    <iframe id=ifram src=table.htm></iframe>
      

  4.   

    非常感谢"seabell(百合心)"!!!!我已完成任务。谢谢!!!送你50分。
      

  5.   

    书上说,切换 className IE做的事情比 直接用JS写样式要多很多...
    呵呵,不过不是主要矛盾.使用HTC,用样式表给所有链接行为这是一个新的趋势...