document.getElementById('div').style.class=''

解决方案 »

  1.   

    我按你的方法 点不出class来啊 
    我自己用的  function show1()
         {
           getmil.className="affairlab2"; 
           sendmail.className="affairlab1"; 
          
          }
        
      

  2.   

    点击后改变div的className
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <style type="text/css">
    .normal, .normal a{
    color:#0000FF;
    }
    .onclick, .onclick a{
    color:#008800;
    }
    </style>
    <script type="text/javascript">
    function $(id){
    return document.getElementById(id);
    }
    window.onload = function(){
    var div = [$("div1"), $("div2"), $("div3")];
    for(var i=0; i<div.length; i++){
    div[i].onclick = function(){
    for(var j=0; j<div.length; j++){
    div[j].className = "onclick";
    };
    };
    }
    };
    </script>
    </head><body>
    <div id="div1" class="normal">文字 <a href="#">链接</a></div>
    <div id="div2" class="normal">文字 <a href="#">链接</a></div>
    <div id="div3" class="normal">文字 <a href="#">链接</a></div>
    </body>
    </html>
      

  3.   

    在 div的 onmouseout 事件里再写一次 onclik 事件 所执行的代码
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <style type="text/css">
    .noclick, .noclick a{
        color:#0000FF;
    }
    .on_click, .on_click a{
        color:#ff0000;
    }
    </style>
    <script type="text/javascript">function show1(_this){
    var obj =_this.parentNode.parentNode.getElementsByTagName("div"),j=obj.length;alert
    for (var i=0;i<j;i++)
    obj[i].className = "noclick";
    _this.parentNode.className = "on_click";
    } </script>
    </head><body>
    <div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div>
    <div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div>
    <div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div>
    </body>
    </html>
      

  5.   

    document.getElementById('div').className=''
      

  6.   


    <body>
    <div class=""><div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div>
    <div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div>
    <div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div></div></body>在你的基础上 外面加个DIV 呢 怎么改啊
      

  7.   

    obj.style.cssText = "color:red;";
      

  8.   


    <script>
    function changech(a){
    var i=1
    for(i=1;i<5;i++){
    var b='c'+i;
    var c='d'+i;
    if(a!=b){
    document.getElementById(b).style.background='url(images/01.gif)  repeat-x';
    document.getElementById(b).style.color='#5c5c5c';
    document.getElementById(c).style.display='none';
    }
    else{
    document.getElementById(b).style.background='url(images/bar_bg.gif)  repeat-x';
    document.getElementById(b).style.color='#ff0000';
    document.getElementById(c).style.display='block';
    }
    }}
    </script>
    这就是一个div控制三个div的JavaScript
      

  9.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <style type="text/css">
    .noclick, .noclick a{
        color:#0000FF;
    }
    .on_click, .on_click a{
        color:#ff0000;
    }
    </style>
    <script type="text/javascript">function show1(_this){
        var obj =_this.parentNode.parentNode.getElementsByTagName("div"),j=obj.length;alert
        for (var i=0;i<j;i++)
            obj[i].className = "noclick";
        _this.parentNode.className = "on_click";
    } </script>
    </head><body>
    <div>
    <div>
    <div>
    <div>
    <div>
    <div>
    <div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div>
    <div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div>
    <div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </body>
    </html>