zoukankan      html  css  js  c++  java
  • js利用定时器动态改变层大小

    <html>
    <head>
        <title></title>
        <script type="text/javascript">
            function showDiv() {
                showIntervalId=setInterval("inc()", 100);
            }
            function inc() {
                var div1 = document.getElementById("div1");
                var oldwidth = div1.style.width;
                oldwidth = parseInt(oldwidth, 10);
                var oldheight = div1.style.height;
                oldheight = parseInt(oldheight, 10);
                if (oldwidth >= 200) {
                    clearInterval(showIntervalId);//停止计时器
                }
                oldwidth += 10;
                oldheight += 10;
                div1.style.width = oldwidth + "px";
                div1.style.height = oldheight + "px";
            }   
        </script>
    </head>
    <body>
    <div id="div1" style=" 10px;height:100px; border-style:solid; border-color:Red; border-1px;">
    中国人最爱上去找中国网站找不到资源的网站中国人最爱上去找中国网站找不到资源的网站
    中国人最爱上去找中国网站找不到资源的网站
    中国人最爱上去找中国网站找不到资源的网站
    </div>
    <input type="button" value="动态放大" onclick="showDiv()" />
    </body>
    </html>

  • 相关阅读:
    go语言goroutine
    go语言接口
    go语言的map
    go语言切片
    go语言数组
    django的信号机制
    python redis 实现简单的消息订阅
    scrapy中使用selenium来爬取页面
    尝试用tornado部署django
    控制台输出太多导致项目启动过慢
  • 原文地址:https://www.cnblogs.com/yichengbo/p/2178103.html
Copyright © 2011-2022 走看看