javascript - Bootstrap progress bar dynamic element - Change width dynamically -


i have 2 progress bars on page. 1 static html version, other 1 created dynamically via jquery. if want change width in jquery progress bar being "progressed" static 1 working.

the other 1 instantly @ 100% without delay.

here code better representation: https://jsfiddle.net/gezgind/dtchh/7133/

html

<div class="container">     <div id="reportbars">         <div class="progress" style="width:500px;margin-bottom:0px;margin-top:20px;">             <div class="progress-bar" id="tracking" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;transition-duration: 3s;">                 <span style="visibility:hidden">xxxx</span>             </div>       </div>       <button id="report_start" type="button" class="btn btn-default">start</button> </div> 

js

 $("#report_start").click(function(){     $("#reportbars").append(         '<div class="progress" style="width:500px;margin-bottom:0px;margin-top:20px;">' +         '<div class="progress-bar" id="tracking1" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;transition-duration: 3s;">' +         '<span style="visibility:hidden">tracking 950.325</span>' +         '</div></div>'     );     $("#tracking").css("width","100%");     $("#tracking1").css("width","100%"); }); 

how fix ?

check out..

new fiddle

you have tweak js code little bit. doing work in 1 go. :

js code:

    /* latest compiled , minified javascript included external resource */  $("#report_start").click(function(){       $("#reportbars").append('<div class="progress" style="width:500px;margin-bottom:0px;margin-top:20px;">'+                             '<div class="progress-bar" id="tracking1" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;transition-duration: 3s;">'+                                 '<span style="visibility:hidden">laufendes tracking 950.325</span>'+                             '</div></div>');          $("#tracking").css("width","100%");     settimeout(function(){$("#tracking1").css("width","100%");},10) }); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -