<!DOCTYPE html> |
< html > |
< head lang = "en" > |
< meta charset = "UTF-8" > |
< title >租借自行车</ title > |
< meta name = "viewport" content = "width=devic-width, initial-scale=1" > |
< link href = "../css/bootstrap.min.css" rel = "stylesheet" /> |
< link href = "../css/style.css" rel = "stylesheet" /> |
</ head > |
< body class = "rent" > |
< div class = "container" > |
< div class = "row" > |
< div class = "col-sm-4 col-sm-offset-4 " > |
< br >< br >< br >< br >< br >< br >< br >< br >< br >< br >< br >< br > |
< div class = "progress progress-striped active" > |
< div class = "progress-bar progress-bar-success" id = "progressId" role = "progressbar" |
aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 0%;" > |
< span id = "tip" >开锁中 40%</ span > |
</ div > |
</ div > |
</ div > |
</ div > |
</ div > |
</ body > |
< script src = "../js/jquery-2.1.0.min.js" ></ script > |
< script src = "../js/bootstrap.min.js" ></ script > |
< script > |
var progress = 0; |
var progressTime = 120;//定时器时间(s) |
var progressPerSecond = Number(100 / progressTime.toFixed(1));//进度条每秒增加的长度 |
var progressTimer = setInterval(function () { |
progressBar() |
}, 1000); |
clearProgress(); |
//进度进度控制 |
function progressBarControl(progressParam) { |
$("#progressId").css("width", progressParam + "%"); |
$("#tip").text("开锁中 " + progressParam + "%"); |
} |
//进度条进度累加 |
function progressBar() { |
progress += progressPerSecond; |
var progressRound = Math.round(progress); |
progressBarControl(progressRound); |
} |
//120s后,清除进度条定时器 |
function clearProgress() { |
setTimeout(function () { |
clearInterval(progressTimer); |
progressBarControl(100);//进度条进度100% |
}, progressTime * 1000); |
} |
</ script > |
</ html > |