zoukankan      html  css  js  c++  java
  • js练习 进度条

    点击开始,读取进度条,数字显示读取百分比

    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <style type="text/css">
        *{ margin:0 auto; padding:0;}
        #wai{ width:320px; height:30px; margin-top:100px;}
        #btn{ width:50px; height:30px; margin-right:20px; background-color:#00F; text-align:center; line-height:30px; color:#fff; float:left;}
        #kuang{ width:200px; height:28px; border:1px solid blue; float:left; }
        #btn:hover{ cursor:pointer;}
        #jindu{ height:28px; background-color:blue; margin-left:0;}
        #shu{ width:30px; height:30px; text-align:center; line-height:30px; float:left;}
    </style>
    </head>
    
    <body>
        <div id="wai">
            <div id="btn">开始</div>
            <div id="kuang">
                <div id="jindu" style=" 0%;"></div>
            </div>
            <div id="shu">0</div>
        </div>
    
    </body>
    </html>
    <script type="text/javascript">
        var btn = document.getElementById("btn");
        var jindu = document.getElementById("jindu");
        var shu = document.getElementById("shu");
        var ids;
        /*
            点击开始读取进度条
        */
        btn.onclick = function()
        {
            ids = window.setInterval("bian()",20)
        }
        /*
            进度条在达到100%前增长1%,数字显示增加1
        */
        function bian()
        {
            var jd = parseInt(jindu.style.width);
            if(jd<100)    
            {
                jd++;
            }
            else
            {
                window.clearInterval(ids);//达到100%清除间隔
            }    
            jindu.style.width = jd+"%";
            shu.innerText = jd;
        }
    
    </script>

    效果 

  • 相关阅读:
    2 爬虫 requests模块
    http协议
    JAVA提高篇
    Java三大特性(封装、继承、多态)
    JavaScript对json对象数组排序(按照某个属性升降序排列)
    js中的闭包
    Java WebService 简单实例
    Quartz 入门详解
    web弹框/层 (layer )的使用
    Shiro
  • 原文地址:https://www.cnblogs.com/zxbs12345/p/8004631.html
Copyright © 2011-2022 走看看