本帖最后由 mute_solo 于 2010-02-04 16:40:16 编辑

解决方案 »

  1.   

    //胡乱写的~<!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>
      <title> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
     </head> <body>
       <ul id="text">
        <li>something 1</li>
        <li>something 2</li>
        <li>something 3</li>
        <li>something 3</li>
        <li>something 5</li>
        </ul><script>
      var lis= document.getElementById('text').childNodes;
      var lastLi=null;
      for(var i=0;i<lis.length;i++)
      {
         lis[i].style.backgroundColor='silver';
         lis[i].onclick=function(event){
            if(null!=lastLi)
            {   
            lastLi.style.backgroundColor='silver';
    }
        this.style.backgroundColor='red';
    lastLi=this;
     };
      }
    </script>
     </body>
    </html>
      

  2.   

    $('#text li:first').click(function () {
        $('#text li:not(:first)').css('color', 'red');
    });
      

  3.   


    <script>
    var lis = document.getElementsByTagName('li');
    for(var i=0;i<lis.length;i++){
      lis[i].onclick = function(){
        GetTheRestLi(this);
    }
    }
    </script>
    我需要上面那个函数 得到不是当前节点的li的数组
      

  4.   

    var lis = document.getElementById('text').getElementsByTagName('li');
      

  5.   

    $("li").click(function(){
    $("#text").children("li").css("color","#ff0000");
    $(this).css("color","");
    })
      

  6.   


    <ul id="text">
    <li>something 1</li>
    <li>something 2</li>
    <li>something 3</li>
    <li>something 4</li>
    <li>something 5</li>
    </ul>
    <script>

    function changeColor(){
    this.id = "text";
    this.childs = null;
    this.init = function(){
    if(this.childs == null)
    this.childs = document.getElementsByTagName("li"); this.bind(this.change);
    } this.change = function(c,tobj){
    for(var i=0;i<tobj.length;i++){
    if(c != tobj[i]){
    tobj[i].style.color = "#990000";
    }
    else{
    c.style.color = "#000000";
    }
    }
    } this.bind = function(callback){
    if(this.childs == null){
    alert("childs is null");
    return;
    }
    var ot = this;
    for(var i=0;i<this.childs.length;i++){
    this.childs[i].onclick = function(){
    callback(this,ot.childs);
    }
    }
    }
    }

    var cObj = new changeColor();
    cObj.init();

    </script>