M-A-T Tory's Blog

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  16 随笔 :: 1 文章 :: 1 评论 :: 0 Trackbacks

首先,更正一下,是只显示了28层,而非27.

下面用了递归,可以清楚的看到你所要创建的表格层数都创建了,只是到显示的时候,从第28层之后都不能显示出来而已.

至于为什么显示不来,我也不得而知.

点击下面的代码,查看结果:

 

<! 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=utf-8 "   />
< title > Untitled Document </ title >
</ head >

< body >
</ body >
</ html >
< script >
var  n  =   40 ;
function  createTable(pI) {
var  oTable  =  document.createElement( " TABLE " );
 oTable.border 
=   1 ;
 oTable.width 
=   1000   -  pI;
 oTable.height 
=   1000   -  pI;
var  oTBody  =  document.createElement( " TBODY " );
var  oTr  =  document.createElement( " TR " );
var  oTd  =  document.createElement( " TD " );
oTd.innerHTML 
=  pI;

if (pI < n)
  oTd.appendChild(createTable(pI
+ 1 ));

oTr.appendChild(oTd);
oTBody.appendChild(oTr);
oTable.appendChild(oTBody);
document.body.appendChild(oTable);
alert(pI)
return  oTable;
}


createTable(
1 );
</ script >
posted on 2006-05-16 19:02 Tory 阅读(270) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理