<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style type="text/css">
#secai{
background: #449D44;
width: 100px;
height: 30px;
background: pink;
}
</style>
<body>
<script type="text/javascript">
window.onload=function (){
var bb;
document.getElementById("bian").onclick=function(){
var jj=100;
bb=setInterval(function () {
jj=jj+20;
document.getElementById("secai").style.width=jj+"px";
if (jj==200) { //设定长度在多少变色
document.getElementById("secai").style.background="#31B0D5";
}
if (jj==400) {
document.getElementById("secai").style.background="#449D44";
}
if (jj==800) {
document.getElementById("secai").style.background="#E38D13";
}
},200) //1000毫秒等于一秒(进度的快慢)
}
}
</script>
<div id="secai"></div>
<input type="button" value="变色" id="bian"> //按钮
</body>
</html>
js篇1-1:div进度条状增长变色
最新推荐文章于 2022-10-05 23:14:26 发布