课程表

jQuery UI 基础

jQuery UI 主题

jQuery UI 部件库

jQuery UI 参考手册

jQuery UI 实例

工具箱
速查手册

进度条(Progressbar)

当前位置:免费教程 » JS/JS库/框架 » jQuery UI

显示一个确定的或不确定的进程状态。

如需了解更多有关 progressbar 部件的细节,请查看 API 文档 进度条部件(Progressbar Widget)

默认功能

默认的确定的进度条。

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI 进度条(Progressbar) - 默认功能</title>
  6. <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  7. <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  8. <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  9. <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
  10. <script>
  11. $(function() {
  12. $( "#progressbar" ).progressbar({
  13. value: 37
  14. });
  15. });
  16. </script>
  17. </head>
  18. <body>
  19. <div id="progressbar"></div>
  20. </body>
  21. </html>

我要试一下

自定义标签

自定义更新的标签。

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI 进度条(Progressbar) - 自定义标签</title>
  6. <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  7. <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  8. <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  9. <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
  10. <style>
  11. .ui-progressbar {
  12. position: relative;
  13. }
  14. .progress-label {
  15. position: absolute;
  16. left: 50%;
  17. top: 4px;
  18. font-weight: bold;
  19. text-shadow: 1px 1px 0 #fff;
  20. }
  21. </style>
  22. <script>
  23. $(function() {
  24. var progressbar = $( "#progressbar" ),
  25. progressLabel = $( ".progress-label" );
  26. progressbar.progressbar({
  27. value: false,
  28. change: function() {
  29. progressLabel.text( progressbar.progressbar( "value" ) + "%" );
  30. },
  31. complete: function() {
  32. progressLabel.text( "完成!" );
  33. }
  34. });
  35. function progress() {
  36. var val = progressbar.progressbar( "value" ) || 0;
  37. progressbar.progressbar( "value", val + 1 );
  38. if ( val < 99 ) {
  39. setTimeout( progress, 100 );
  40. }
  41. }
  42. setTimeout( progress, 3000 );
  43. });
  44. </script>
  45. </head>
  46. <body>
  47. <div id="progressbar"><div class="progress-label">加载...</div></div>
  48. </body>
  49. </html>

我要试一下

不确定的值

不确定的进度条,并可在确定和不确定的样式之间切换。

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI 进度条(Progressbar) - 不确定的值</title>
  6. <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  7. <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  8. <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  9. <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
  10. <script>
  11. $(function() {
  12. $( "#progressbar" ).progressbar({
  13. value: false
  14. });
  15. $( "button" ).on( "click", function( event ) {
  16. var target = $( event.target ),
  17. progressbar = $( "#progressbar" ),
  18. progressbarValue = progressbar.find( ".ui-progressbar-value" );
  19. if ( target.is( "#numButton" ) ) {
  20. progressbar.progressbar( "option", {
  21. value: Math.floor( Math.random() * 100 )
  22. });
  23. } else if ( target.is( "#colorButton" ) ) {
  24. progressbarValue.css({
  25. "background": '#' + Math.floor( Math.random() * 16777215 ).toString( 16 )
  26. });
  27. } else if ( target.is( "#falseButton" ) ) {
  28. progressbar.progressbar( "option", "value", false );
  29. }
  30. });
  31. });
  32. </script>
  33. <style>
  34. #progressbar .ui-progressbar-value {
  35. background-color: #ccc;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="progressbar"></div>
  41. <button id="numButton">随机值 - 确定</button>
  42. <button id="falseButton">不确定</button>
  43. <button id="colorButton">随机颜色</button>
  44. </body>
  45. </html>

我要试一下

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号