<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<table width="200" border="1" id="tab">
  <tr>
    <td>1</td>
    <td>2</td>
    <td><input type="text" id="test" onblur="fun(this)"/></td>
  </tr>
</table><script type="text/javascript">
function fun(el)
{
alert(el.parentNode.cellIndex);
}
</script>
</body>
</html>

解决方案 »

  1.   

    一定要传递一个this吗?td=event.target;不可以代替吗?
      

  2.   


    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <body>
    <table width="200" border="1" id="tab">
      <tr>
        <td>1</td>
        <td>2</td>
        <td><input type="text" id="test" onblur="fun(event)"/></td>
      </tr>
    </table><script type="text/javascript">
    function fun(event)
    {
    var e=window.event||event;
    var src=e.srcElement||e.target;
        alert(src.parentNode.cellIndex);
    }
    </script>
    </body>
    </html>