首页 > 代码库 > JS实例之进度条制作,实现进度条读条效果

JS实例之进度条制作,实现进度条读条效果

 1 <head>
 2 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 3 <title>无标题文档</title>
 4 <style type="text/css">
 5 *{margin:0px auto; padding:0px;}
 6 #wai{width:200px; height:20px; margin-top:100px; border:1px solid #666;}
 7 #nei{width:0%; height:20px; background-color:#F00; float:left;}
 8 </style>
 9 </head>
10 
11 <body>
12     <div id="wai">
13         <div id="nei"></div>
14     </div>
15     <input type="button" value="开始" onclick="zou()"/>
16 </body>
17 <script type="text/javascript">
18 var a=0;
19 function zou(){
20     if(a<100){
21         a++;
22     }
23     document.getElementById("nei").style.width =a+"%";
24     window.setTimeout("zou()",5);
25 }
26 </script>
27 </html>

 

JS实例之进度条制作,实现进度条读条效果