jquery简单进度条一例

发布时间:2019-10-31编辑:脚本学堂
本文介绍一个jquery实现的简单进度条代码,有需要的朋友,参考下吧。

jquery/jindutiao/ target=_blank class=infotextkey>jquery进度条的代码,如下:
 

复制代码 代码示例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery 进度条 - www.jb200.com</title>
<script type="text/javascript" src="include/jquery-1.8.2.js"></script>
<script type="text/javascript">
var progress_id = "loading";
function SetProgress(progress) {
if (progress) {
$("#" + progress_id + " > div").css("width", String(progress) + "%"); //控制#loading div宽度
$("#" + progress_id + " > div").html(String(progress) + "%"); //显示百分比
}
}
var i = 0;
function doProgress() {
if (i > 100) {
$("#message").html("全部备份成功!").fadeIn("slow");//加载完毕提示
return;
}
if (i <= 100) {
setTimeout("doProgress()", 100);
SetProgress(i);
i++;
}
}
$(document).ready(function() {
doProgress();
});
</script>
<style type="text/css">
#center{
margin:50px auto;
width:400px;
}
#loading{
width:397px;
height:49px;
background:url(images/bak.png) no-repeat;
}
#loading div{
width:0px;
height:48px;
background:url(images/pro.png) no-repeat;
color:#fff;
text-align:center;
font-family:Tahoma;
font-size:18px;
line-height:48px;
}
#message{
width:200px;
height:35px;
font-family:Tahoma;
font-size:12px;
background-color:#d8e7f0;
border:1px solid #187CBE;
display:none;
line-height:35px;
text-align:center;
margin-bottom:10px;
margin-left:50px;
}
</style>
</head>
<body>
<div id="center">
<div id="message">脚本学堂</div>
<div id="loading"><div></div>欢迎大家的光临!</div>
</div>
</body>
</html>