kisukedeath

Animated Progress Bar - Jquery

Nov 14th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.61 KB | None | 0 0
  1. HTML:
  2.  
  3. <div id="progressBar"><div></div></div>
  4.  
  5. CSS:
  6.  
  7. #progressBar {
  8.         width: 400px;
  9.         height: 22px;
  10.         border: 1px solid #111;
  11.         background-color: #292929;
  12. }
  13.  
  14. #progressBar div {
  15.         height: 100%;
  16.         color: #fff;
  17.         text-align: right;
  18.         line-height: 22px; /* same as #progressBar height if we want text middle aligned */
  19.         width: 0;
  20.         background-color: #0099ff;
  21. }
  22.  
  23. JQUERY:
  24.  
  25. function progress(percent, $element) {
  26.     var progressBarWidth = percent * $element.width() / 100;
  27.     $element.find('div').animate({ width: progressBarWidth }, 500).html(percent + "%&nbsp;");
  28. }
  29.  
  30. progress(80, $('#progressBar'));
Advertisement
Add Comment
Please, Sign In to add comment