当前位置:asp编程网>技术教程>Javascript教程>  正文

动态改变表格的宽度和起点位置

2007-11-13 11:03:53   来源:    作者:佚名   浏览量:1959   收藏
有时候需要动态改变表格的宽度和起点位置,可以用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>

关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网