国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

bootstrap+jQuery實(shí)現(xiàn)的動(dòng)態(tài)進(jìn)度條功能示例

2019-11-19 16:29:21
字體:
供稿:網(wǎng)友

本文實(shí)例講述了bootstrap+jQuery實(shí)現(xiàn)的動(dòng)態(tài)進(jìn)度條功能。分享給大家供大家參考,具體如下:

此款進(jìn)度條實(shí)現(xiàn)的功能:

1.利用了bootstrap的進(jìn)度條組件。

a.在最外層的<div>中加入class .progress,在里層<div>加入class .progress-bar從而實(shí)現(xiàn)基本的進(jìn)度條。
b.在外層<div>中加入class .progress-striped實(shí)現(xiàn)條紋進(jìn)度條。
c.在內(nèi)層<div>加入class .progress-bar-danger/warning/info/success 從而實(shí)現(xiàn)紅色、黃色、藍(lán)色、綠色
d.在外層<div>中加入class .active 實(shí)現(xiàn)動(dòng)畫效果

2.利用jQuery對(duì)進(jìn)度條進(jìn)度進(jìn)行控制。

0-30時(shí)顯示紅色,30-60顯示黃色,60-90顯示綠色,90-100顯示綠色
實(shí)現(xiàn)進(jìn)度條暫停、停止、重新開始、繼續(xù)功能

具體代碼如下:

<!DOCTYPE html><html lang="zh-CN"><head>  <meta charset="UTF-8">  <title>...</title>  <!--在IE瀏覽器中運(yùn)行最新的渲染模式-->  <meta http-equiv="X-UA-Compatible" content="IE-Edge">  <!--初始化移動(dòng)瀏覽器顯示-->  <meta name="viewport" content="width-device-width,inital-scale=1">  <link  rel="external nofollow" rel="stylesheet">  <link rel="stylesheet" type="text/css" href="index.css" rel="external nofollow" >  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>   <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>   <script type="text/javascript">     $(document).ready(function(){       var value = 0;       var time = 50;       //進(jìn)度條復(fù)位函數(shù)       function reset( ) {        value = 0         $("#prog").removeClass("progress-bar-success").css("width","0%").text("等待啟動(dòng)");         //setTimeout(increment,5000);       }       //百分?jǐn)?shù)增加,0-30時(shí)為紅色,30-60為黃色,60-90為藍(lán)色,>90為綠色       function increment( ) {         value += 1;         $("#prog").css("width",value + "%").text(value + "%");         if (value>=0 && value<=30) {           $("#prog").addClass("progress-bar-danger");         }         else if (value>=30 && value <=60) {           $("#prog").removeClass("progress-bar-danger");           $("#prog").addClass("progress-bar-warning");         }         else if (value>=60 && value <=90) {           $("#prog").removeClass("progress-bar-warning");           $("#prog").addClass("progress-bar-info");         }         else if(value >= 90 && value<100) {           $("#prog").removeClass("progress-bar-info");           $("#prog").addClass("progress-bar-success");         }         else{           setTimeout(reset,3000);           return;         }         st = setTimeout(increment,time);       }       increment();       //進(jìn)度條停止與重新開始       $("#stop").click(function () {         if ("stop" == $("#stop").val()) {           //$("#prog").stop();           clearTimeout(st);           $("#prog").css("width","0%").text("等待啟動(dòng)");           $("#stop").val("start").text("重新開始");         } else if ("start" == $("#stop").val()) {           increment();           $("#stop").val("stop").text("停止");         }       });       //進(jìn)度條暫停與繼續(xù)       $("#pause").click(function() {         if ("pause" == $("#pause").val()) {           //$("#prog").stop();           clearTimeout(st);           $("#pause").val("goon").text("繼續(xù)");         } else if ("goon" == $("#pause").val()) {           increment();           $("#pause").val("stop").text("暫停");         }       });     });   </script></head><body>  <div class="progress progress-striped active">    <div id="prog" class="progress-bar" role="progressbar" aria-valuenow="" aria-valuemin="0" aria-valuemax="100" style="width:0%;">      <span id="proglabel">正在啟動(dòng),請(qǐng)稍后......</span>    </div>  </div>  <div class="form-group">    <div class="col-sm-offset-4 col-sm-6">      <button id="pause" class="btn btn-primary" value="pause">暫停</button>      <button id="stop" class="btn btn-primary" value="stop">停止</button>      <!--<button id="goon" class="btn btn-primary">繼續(xù)<button>-->    </div>  </div></body></html>

PS:關(guān)于bootstrap布局,這里再為大家推薦一款本站的在線可視化布局工具供大家參考使用:

在線bootstrap可視化布局編輯工具:
http://tools.VeVB.COm/aideddesign/layoutit

希望本文所述對(duì)大家基于bootstrap的程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 玛纳斯县| 浪卡子县| 视频| 镇雄县| 镇江市| 义马市| 枣强县| 井冈山市| 和硕县| 双流县| 台中县| 清丰县| 苏尼特右旗| 来凤县| 苍溪县| 张家川| 葵青区| 错那县| 德钦县| 苗栗县| 封开县| 阜宁县| 仁化县| 阿克| 宜春市| 喜德县| 泗阳县| 民县| 资源县| 阜南县| 磐石市| 边坝县| 潜山县| 沛县| 肃宁县| 盐源县| 内丘县| 贵德县| 孟州市| 汶川县| 文化|