<!DOCTYPE html> <html> <head> <meta charset="utf8" /> <title>progressbar</title> <style type="text/css"> #divprogressbar{ width:300px; height:30px; } .progress-label{ float:left; margin-left:40%; margin-top:3px; } </style> <link rel="stylesheet" href="css/jquery-ui-1.10.4.min.css" media="screen"/> <script type="text/javascript" src="js/jquery-1.10.2.js"></script> <script type="text/javascript" src="js/jquery-ui-1.10.4.min.js"></script> </head> <body> <div id="divprogressbar"><div class="progress-label">loading...</div></div> <script type="text/javascript"> $(function(){ // var val=0; $('#divprogressbar').progressbar({value:0}); $('#divprogressbar').progressbar({ value:0, change:function(){ $(".progress-label").text($("#divprogressbar").progressbar("value")+"%"); }, complete:function(){ $(".progress-label").text("Complete!"); } }); function progress(){ var val= $('#divprogressbar').progressbar("value") || 0; $('#divprogressbar').progressbar("option","value",val+1); if(val<99) { setTimeout(progress,100); } } setTimeout(progress,1000); } ); </script> </body> </html>
查看文檔:http://jqueryui.com/progressbar/javascript