?????? Js 动态修改表格内容、对齐表格内的内容,主要是控制表格的TableRow对象属性,使其左对齐、右对齐、向上对齐等,大家可以根据代码进行扩展,例如学习添加向下对齐等。
<html> <head> <title>TableRow对象的属性</title> <script language="JavaScript"> function cellContent(){ var objRow = myTable.rows; var objCell = objRow[0].cells; objCell[0].innerText = "CGI"; objCell[1].innerText = "ASP"; } </script> </head> <body> <h2>TableRow对象的属性</h2> <hr> <table id="myTable" border=1> <tr> <td>HTML</td> <td>CSS</td> </tr> <tr> <td height="50">JavaScript</td> <td height="50">VBScript</td> </tr> </table> <form> <input type="button" onclick="cellContent()" value="单元格内容"> <input type="button" onclick="myTable.rows[0].align='right';" value="向右对齐"> <input type="button" onclick="myTable.rows[1].vAlign='top';" value="向上对齐"> </form> </body> </html>
?
?