用javascript设计进度条,要求点击“开始”按钮后,进度条才开始运行...
发布网友
发布时间:2022-04-26 18:39
我来回答
共1个回答
热心网友
时间:2022-05-16 12:09
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TestPage</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
function tt(){
var barObj = document.getElementById("proBar");
var currentWidth = parseInt(barObj.style.width.substring(0, barObj.style.width.length - 1));
if (currentWidth < 400) {
barObj.style.width = (currentWidth + 1) + "px";
}
else{return ;}
setTimeout("tt()", 10);
}
</script>
</head>
<body>
<div id="proBar" style="width:0px;background-color:green;color:white">processbar</div>
<input type="button" id="btn1" onclick="tt()" value="start">
</body>
</html>