日期:2014-05-16  浏览次数:20422 次

100分求 表格的控制
document.getElementById( "div3 ").innerHTML   =   " <table> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr>
<tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr>
<tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr>
</table> ";
我用这个为什么不能控制表格的td显示与隐藏亚
var   tbl     =   document.getElementById( 'mytable ');
var   rows   =   tbl.getElementsByTagName( 'tr ');
var   cels   =   rows[row].getElementsByTagName( 'td ')
            cels[col_no].style.display=stl;

------解决方案--------------------
注意td是不能隐藏的,tr和table都可以

<input type= "button " name= "Submit " value= "发布前必读 " onClick= "if (document.getElementById( 'dd ').style.display== 'none '){document.getElementById( 'dd ').style.display= 'block '} else {document.getElementById( 'dd ').style.display= 'none '} ">
------解决方案--------------------
sorry,td是可以隐藏的,好长时间不写了都糊涂了。
搂主要给td指定id
------解决方案--------------------
可以呀~
<!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>
<script type= "text/javascript ">
function a(){
document.getElementById( "div3 ").innerHTML = " <table border=1> <tr> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr> </table> ";
}
function dis(){
var tbl = document.getElementById( 'div3 ');
var rows = tbl.getElementsByTagName( 'tr ');
var cels = rows[2].getElementsByTagName( 'td ')
cels[1].style.display= "none ";
}

</script>
<body onload= "a() ">
<div id= "div3 ">

</div>

<input type= "button " onclick= "dis() " value= "隐藏 "/>
</body>
</html>
------解决方案--------------------
这样~

<!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>
<script type= "text/javascript ">
function a(){
document.getElementById( "div3 ").innerHTML = " <table border=1> <tr> <td> &nbsp; &l