有时候需要动态改变表格的宽度和起点位置,可以用javascript来实现,代码如下,也可以用此方法更改表格的其他属性<script language="javascript" type="text/javascript"><!-- function onInformation(){ theNum=parseInt(document.getElementById("layer1").width); theNum+=parseInt(document.form1.aaa.value); document.getElementById("layer1").setAttribute("width",theNum); document.getElementById("layer1").style.left=parseInt(document.getElementById("layer1").style.left.replace("px",""))+100; }--></script><div id="la"> <table width="100" height="300" id="layer1" style="LEFT: 200px; TOP:60px;POSITION: absolute;"> <form name="form1" method="post"> <tr height="20"> <td height="24" bgcolor="#0033FF"></td> </tr> <tr height="180" valign="top"> <td bgcolor="#99FF99" > <h3>Hello</h3> <input type="text" name="aaa" size=10/> <input type="button" onclick="return onInformation();" value="扩大"/> </td> </tr> </form></table> </div>

评论