1. 程式人生 > >bootstrap 假的動態進度條O(∩_∩)O~

bootstrap 假的動態進度條O(∩_∩)O~

html部分

<div class="modal fade" data-backdrop="static" tabindex="-1" id="myModal1">  
         <!--視窗宣告:-->  
         <div class="modal-dialog modal-lg">  
              <!-- 內容宣告 -->  
              <div class="modal-content">  
                  <!-- 主體 -->  
                   <div
class="modal-body">
<div class="progress progress-striped active"> <div id="test" class="progress-bar progress-bar-success" role="progressbar" style="width: 10%;"> </div> </div
>
</div> </div> </div> </div>

js部分


                var p = 10;  
                var stop = 0; 
                ...
                $('#myModal1').modal('show');  
                //呼叫進度條
                page_funs.start_progress();
                ...
ajax-->success-->stop=1 ... //啟動進度條 start_progress:function() { p += 4; //進度條每秒走4個單位 if(stop==1){//ajax返回success時,stop=1 $("#test").css("width", "100%"); setTimeout(" $('#myModal1').modal('hide'); ", 1000); return; } $("#test").css("width", p + "%"); //每秒執行一次 var timer = setTimeout("page_funs.start_progress()", 1000); }