一个奇怪的关于Table的offsetHeight问题

cql0007 2003-06-24 08:32:52
for(i=1;i<the10Table.rows.length;i++){
the10Table.rows[i].height = the11Table.rows[i].offsetHeight;
the11Table.rows[i].height = the10Table.rows[i].offsetHeight;
}

上面的代码是让the10Table和the11Table的高度保持一致,当其中一个有变化时另一个也跟着变化.上面的代码没有问题的,可表格的行号和列号是从0开始的,当我把上面的循环中的i设为i=0的时候,就出错了.出错提示为:参数无效.
我单独写出来;
the10Table.rows[0].height= the11Table.rows[0].offsetHeight 还是和上面的写法一样的出错,可当我将上面的一句分成两个:
alert(the10Table.rows[0].height);
alert(the11Table.rows[0].offsetHeight);
它又居然不出错了,真是莫明其妙啊.
...全文
142 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cql0007 2003-07-04
  • 打赏
  • 举报
回复
呵呵,是没问题,是我自己的代码出了问题.
kingdomzhf 2003-06-24
  • 打赏
  • 举报
回复

<table id=the10Table border=1>
<tr>
<td>a</td>
</tr>
</table>
<table id=the11Table border=1>
<tr>
<td>a</td>
</tr>
</table>
<script>

for(i=0;i<the10Table.rows.length;i++){
the10Table.rows[i].height = the11Table.rows[i].offsetHeight;
the11Table.rows[i].height = the10Table.rows[i].offsetHeight;
}
</script>

have no problem

87,987

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧