点击时改变该行颜色,并记录该行ROWID,再次点击通过ROWID进行判断;

解决方案 »

  1.   

    ROWID是什么啊?
    怎么设置?
    <tr id="tr1">?
      

  2.   

    <tr onclick="alert(this.rowIndex);"><td>test</td></tr>
      

  3.   

    可以在每行前虚拟一个checkbox 可以记录该行的id 当点击该行时相当于选中一checkbox 那么该行变色, 再次发生改变时就是checkbox 状态改变的时候
      

  4.   

    <style>
    tr{
        cursor:hand;
    }
    tr.tr_1 {
     background-color:white;
    }
    tr.tr_2{
     background-color:Aqua;
    }
    tr.checked{
     background-color:pink ;
    }
    tr.over{
         background-color:lime;
    }
    </style>
    <script>
    function initTableCss(){
        var tab=document.getElementById("tab");
        for(var i=0;i<tab.rows.length;i++){
            tab.rows[i].className=(i%2==1)?"tr_1":"tr_2";
            tab.rows[i].checked=false;
            tab.rows[i].onclick=theCheckEvent;
            tab.rows[i].onmouseover=theOverEvent;
             tab.rows[i].onmouseout=theOutEvent;
        }
    }
    function theCheckEvent(){
        if(this.checked){
            this.checked=false;
            this.className=(this.rowIndex%2==1)?"tr_1":"tr_2";
        }else{
            this.checked=true;
            this.className="checked";
        }
    }
    function theOverEvent(){
        this.className="over";
    }
    function theOutEvent(){
        if(this.checked==false){
            this.className=(this.rowIndex%2==1)?"tr_1":"tr_2";
        }else{
            this.className="checked";
        }
    }
    window.onload=initTableCss;
    </script>
    <table id="tab" />
        <tr><td>11111111111111111</td><td>2222222222222222</td></tr>
        <tr><td>11111111111111111</td><td>2222222222222222</td></tr>
        <tr><td>11111111111111111</td><td>2222222222222222</td></tr>
        <tr><td>11111111111111111</td><td>2222222222222222</td></tr>
        <tr><td>11111111111111111</td><td>2222222222222222</td></tr>
        <tr><td>11111111111111111</td><td>2222222222222222</td></tr>
        <tr><td>11111111111111111</td><td>2222222222222222</td></tr>
        <tr><td>11111111111111111</td><td>2222222222222222</td></tr>
    <table>
      

  5.   

     onmouseover="c=this.style.backgroundColor;this.style.backgroundColor='#00ffee'" onmouseout="this.style.backgroundColor=c" onmousedown="c=this.style.backgroundColor"