分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

JS实现 进度条 不用控件

发布时间:2023-09-06 02:34责任编辑:白小东关键词:暂无标签

demo1

<html> <head> <title>进度条</title> <style type="text/css"> ?.container{ ????width:450px; ????border:1px solid #6C9C2C; ????height:25px; ??}#bar{ ????background:#95CA0D; ????float:left; ???height:100%; ????text-align:center; ????line-height:150%; ?} ?</style> ?<script type="text/javascript"> ???function run(){ ?????????var bar = document.getElementById("bar"); ????????var total = document.getElementById("total"); ????bar.style.width=parseInt(bar.style.width) + 1 + "%"; ?????total.innerHTML = bar.style.width; ????if(bar.style.width == "100%"){ ???????window.clearTimeout(timeout); ??????return; ????} ????var timeout=window.setTimeout("run()",100); ??} ????window.onload = function(){ ????????run(); ????} ?</script> ??</head> <body> ??<div class="container"> ???<div id="bar" style="width:0%;"></div> ???</div> ???<span id="total"></span> </body> </html>

demo2

<html> ?<head> ?<title>进度条</title> ?<style type="text/css"> ?.processcontainer{ ????width:450px; ????border:1px solid #6C9C2C; ????height:25px; ??} #processbar{ ????background:#95CA0D; ????float:left; ???height:100%; ????text-align:center; ????line-height:150%; ?} ?</style> ?<script type="text/javascript"> ??function setProcess(){ ???var processbar = document.getElementById("processbar"); ???processbar.style.width = parseInt(processbar.style.width) + 1 + "%"; ?processbar.innerHTML = processbar.style.width; ???if(processbar.style.width == "100%"){ ??????window.clearInterval(bartimer); ???} ??} ?var bartimer = window.setInterval(function(){setProcess();},100); ?window.onload = function(){ ????bartimer; ?} ?</script> ?</head> ?<body> ???<div class="processcontainer"> ????<div id="processbar" style="width:0%;"></div> ???</div> ?</body> ?</html>

JS实现 进度条 不用控件

原文地址:https://www.cnblogs.com/sea-stream/p/10449755.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved