<table width="75%" border="0">
  <tr>
    <td background="0.jpg">1</td>
    <td background="0.jpg">2</td>
    <td background="0.jpg">3</td>
  </tr>
</table>
这样表格  请怎么写  点 1 的时候 变成 <table width="75%" border="0">
  <tr>
    <td background="1.jpg">1</td>
    <td background="0.jpg">2</td>
    <td background="0.jpg">3</td>
  </tr>
</table>点  2 的时候 变成 <table width="75%" border="0">
  <tr>
    <td background="0.jpg">1</td>
    <td background="1.jpg">2</td>
    <td background="0.jpg">3</td>
  </tr>
</table>
点 3 的时候 变成 <table width="75%" border="0">
  <tr>
    <td background="0.jpg">1</td>
    <td background="0.jpg">2</td>
    <td background="3.jpg">3</td>
  </tr>
</table>

解决方案 »

  1.   


    <script type="text/javascript"> 
    var cur;
    function doit(obj){
    if(cur == obj) return;
    if(cur!=null) cur.style.background = "url(0.jpg)";
    obj.style.background = "url(1.jpg)";
    cur = obj;
    }
    </script> <table width="75%" border="0"> 
      <tr> 
        <td background="0.jpg" onclick="doit(this)">1 </td> 
        <td background="0.jpg" onclick="doit(this)">2 </td> 
        <td background="0.jpg" onclick="doit(this)">3 </td> 
      </tr> 
    </table>
      

  2.   


    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    window.onload = function(){
    var oTDs = document.getElementsByTagName('td');
    for(var i = 0; i < oTDs.length; i++){(function(obj,i){
    obj.onclick = function(){
    if(obj.background == '0.jpg'){
    obj.background = '1.jpg';
    alert(obj.background);
    }else{
    obj.background = '0.jpg';
    }

    }

    }(oTDs[i],i))

    }
    };
    </script>
    </head><body>
    <table width="75%" border="0">
      <tr>
    <td background="0.jpg">1 </td>
    <td background="0.jpg">2 </td>
    <td background="0.jpg">3 </td>
      </tr>
    </table> 
    </body>
    </html>