日期:2014-05-16 浏览次数:20482 次
<script language="javascript"> function start(){ mybody = document.getElementsByTagName ("body").item(0); mytable = document.createElement("TABLE"); mytablebody = document.createElement("TBODY"); for(j=0;j<2;j++){ mycurrent_row = document.createElement("TR"); for(i=0;i<2;i++){ mycurrent_cell= document.createElement("TD"); currenttext=document.createTextNode("cell is row "+j+", column "+i); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); } mytablebody.appendChild(mycurrent_row); } mytable.appendChild(mytablebody); mybody.appendChild(mytable); mytable.setAttribute("border","2"); } </script>?原来mybody = document.getElementsByTagName? ("body").item(0);是mybody =???? document.getElementsByTagName? ("body");写的,报错“对象不支持属性或方法”后来发现getElementsByTagName()方法返回一个集合,所以改成代码中的写法通过。很不好找呀