html与js生成的滚动条
作者:
无敌万小奔 | 来源:发表于
2017-05-24 14:30 被阅读0次<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
#d1 {
width: 800px;
height: 40px;
border: 2px solid black;
}
#d2 {
width: 0;
height: 40px;
background: blue;
}
</style>
</head>
<body>
<h1>滚动条</h1>
<hr>
<div id="d1">
<div id="d2"></div>
</div>
<br>
<button id="btn">开始</button>
</body>
<script>
var oDiv2=document.getElementById('d2');
var oBtn=document.getElementById('btn');
var i=document.getElementById('d2').style.width;
oBtn.onclick=function(){
var timer=setInterval(run,10);
function run(){
if(i==800){
return;
}
i++;
oDiv2.style.width=i+'px';
}
}
</script>
</html>
本文标题:html与js生成的滚动条
本文链接:https://www.haomeiwen.com/subject/rofoxxtx.html
网友评论