<table>
<tr>
<td onclick="this.style.backgroundColor= this.style.backgroundColor == 'red' ? '':'red';" ondblclick="window.location.href='http://www.csdn.net';">click here
</td>
</tr>
</table>

解决方案 »

  1.   

    用一个全局变量保存当前激活的记录
    <script>
    var activeRow=null
    function foo(){
    ob=window.event.srcElement;
    if(ob!=activeRow){
    if(activeRow!=null) activeRow.style.backgroundColor="";
    ob.style.backgroundColor="red";
    activeRow=ob;
    }else{
    activeRow=null;
    ob.style.backgroundColor=""
    }
    }
    </script>
    <table>
    <tr>
    <td onclick="foo()" ondblclick="window.location.href='http://www.csdn.net';">click here
    </td>
    </tr>
    <tr>
    <td onclick="foo()" ondblclick="window.location.href='http://www.csdn.net';">click here
    </td>
    </tr>
    </table>
      

  2.   

    一次只能选中一个纪录? what do you mean? how many records are in that <td>?
      

  3.   

    我的纪录是放在<tr>中的 ,这样可以选中一个记录吧?
    现在有个 问题 ,我 的记录不是很多 ,基本上 最多情况下100条而已,我要做分页,就是每页显示八个纪录,我想只操纵数据库一次,读出所有纪录,然后让其他纪录disable,也就是只限是当前的8个纪录,点下一页就显示下面8个纪录,这个怎么实现?