JavaScript案例之加载进度条
源码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.fa{
width: 400px;
margin-bottom: 30px;
border: 1px solid red;;
}
.son{
width: 0px;
height: 40px;
background-color: #f0f;
text-align: center;
line-height: 40px;
}
</style>
</head>
<body>
<div class="fa">
<div class="son">
<span>0</span><span>%</span>
</div>
</div>
<button id="but">安装</button>
<script>
// 逻辑:1.利用定时器来进行递增操作(width、百分数)
// 2.当变量 达到400px时,是停止定时器
let but =