JavaScript复习--点击按钮,div边框(宽和高)动态增加

 <script type="text/javascript">
        var setinterval;
        function showInc()
        {
            setinterval = setInterval("add()",100);
        }

        function add()
        {
            var ddd = document.getElementById("divv");
            var width = parseInt(ddd.style.width,10);
            var height = parseInt(ddd.style.height, 10);
            width = width + 10;
            height = height + 10;
            if (width>500) {
                clearInterval(setinterval);
            }
            ddd.style.width = width + "px";
            ddd.style.height = height + "px";
        }
    </script>
</head>
<body>
    <div id="divv" style="border:1px solid #0d0c0c;width:200px;height:200px">
        画鸡
        <table>
            <tr>
                <td>头上红冠不用彩,</td>
            </tr>
              <tr>
                <td>满身雪白走将来。</td>
            </tr>
             <tr>
                <td>平生不敢轻言语,</td>
            </tr>
              <tr>
                <td> 一叫千门万户开。</td>
            </tr>
        </table>
    </div>
      <input type="button" value="动态增加"  onclick="showInc();"/>
</body>

JavaScript复习--点击按钮,div边框(宽和高)动态增加,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。