js仿真进度条

js仿真进度条

<script type="text/javascript">
        // 思路  不断改变fillDiv的宽度
        function $(id) {
        	return document.getElementById(id);
        }  
		var timer=setInterval(setTimer,10);
		function setTimer(){
			 $("fillDiv").style.width=$("fillDiv").clientWidth+2+"px";
			 var percent=parseInt(100*($("fillDiv").clientWidth/$("progress").clientWidth))+"%";	
			 $("percent").innerHTML=percent;
			 if($("fillDiv").clientWidth>=200){
				clearInterval(timer);
			  }
		}  
    </script>

猜你喜欢

转载自blog.csdn.net/lixiaoyan_star/article/details/85696060