我有一个 
var TdList=一个Table的Td对象
TdList.outerHTML="<TD rowSpan=2 y="0" x="0">&nbsp;{%table-cell%}</TD>";我怎么取得y与x的值????????????最好能把X与Y变成一个属性,谢谢!

解决方案 »

  1.   


     <TABLE border=1>
     <TR>
    <TD id="td1" rowSpan=2 y="0" x="0" xy="1,1">&nbsp;{%table-cell%}</TD>
    <TD>1111</TD>
     </TR>
     <TR>
    <TD>&nbsp;222</TD>
     </TR>
     </TABLE>
      <SCRIPT LANGUAGE="JavaScript">
      <!--
    var TdList =td1;
    alert("x="+TdList.x +";y="+ TdList.y+";xy="+ TdList.xy);
      //-->
      </SCRIPT>
      

  2.   

    firefox的话
    TDList.x 改成 TDList.getAttribute("x") 以此类推……
      

  3.   

        <!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>无标题页</title>
      <style type="text/css">
      div {width:200;height:40;color:red}
      </style>
        
    <script type="text/javascript">      window.onload = function()
          {
              document.getElementById('td1').onclick = function()
              {
                  alert(this.getAttribute("x"));
                  alert(this.getAttribute("y"));
              }
          };
    </script>
    </head>
    <body><table >
        <tr>
            <td id="td1" x="0" y="1">点击这里</td>
        </tr>
    </table>
    </body>
    </html>
      

  4.   

    谢谢了,问题我自己已经解决了谢谢二楼的getAttribute提醒, 呵
      

  5.   

    firefox 和 IE  取值有的时候需要注意TDList.x 改成 TDList.getAttribute("x")alert("x="+TdList.x +";y="+ TdList.y+";xy="+ TdList.xy);