我需要实现鼠标点击行 改变行的颜色,是点击行才改变颜色
按住鼠标左键 向上或下移动 光标经过的行都被选定 都会改变颜色 
怎么实现啊 ~?? 急~

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    </head>
    <script language="JavaScript">
    <!--
    var curObj= null;
    var isTrue =false;
    function setSelectedBgColor(){
    isTrue =true;
     if(window.event.srcElement.tagName=='TD'){
    //if(curObj!=null) curObj.style.background='';
    curObj=window.event.srcElement.parentElement;
    curObj.style.background='#ffdead';
       }
       else if(window.event.srcElement.tagName=='SPAN')
       {
    if(curObj!=null) curObj.style.background='';
    curObj=window.event.srcElement.parentElement.parentElement;
    curObj.style.background='#ffdead';
       }
       }
    //-->
    </script>
    <body>
    <table border="1" width=200 height=200 onmousemove= "if(isTrue)setSelectedBgColor();" onmousedown="setSelectedBgColor();" onmouseup="isTrue =false;">
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </body>
    </html>