jqueryui(四)進度條progressbar

進度條可以向用戶顯示程序當(dāng)前完成的百分比,讓用戶知道程序的進度,提高了用戶體驗。而jquery ui 則提供一個非常便捷的方法實現(xiàn)這一功能,就是progressbar.

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),寧強企業(yè)網(wǎng)站建設(shè),寧強品牌網(wǎng)站建設(shè),網(wǎng)站定制,寧強網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,寧強網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。

一、 老規(guī)矩,先上一個簡單的例子

1、代碼如下:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script type="text/javascript">
  $(function(){
     $("#progressbar1").progressbar({value:7});
});

</script>
<div id="progressbar1">
<div class="progress-label">ifxoxo.com..7%</div>
</div>

2、 效果圖如下:

jquery ui(四)進度條 progressbar

jQuery UI Progressbar –ifxoxo

二、具體用法

1、需要加載的js文件

(1)jquery.js
(2)jquery.ui
(3)jquery.ui的css

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

2、頁面上的html代碼

需要一個用來裝progressbar的空容器

<div id="divProgerssbar"></div>

3、js代碼

初始化函數(shù):$(.selecter).progressbar()
(1)options

它有三個參數(shù)可以使用

參數(shù) 默認值 作用
value 0 進度條顯示的度數(shù)(0到100)
max 100 進度條的最大值
disable false 是否隱藏
(2)事件
  • create: 加載progressbar的時候此事件將被觸發(fā)

  • change: 進度條有改變的時候此事件將被觸發(fā)

  • complete: 加載到100的時候此事件將被觸發(fā)

4、一個會動的進度條的實例

(1)代碼如下
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>jQuery UI Progressbar - Custom Label</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style>
//為了讓樣式清晰一點
.ui-progressbar {
   position: relative;
}
.progress-label {
   position: absolute;
   left:50%;
   top: 4px;
   font-weight: bold;
   text-shadow: 1px 1px 0#fff;
}
</style>
<script>
 $(function(){
var pro = $("#progressbar");//進度條div
var proLabel = $(".progress-label");//進度條里面文字

   pro.progressbar({
     value:false,//初始化的值為0
     change:function(){
//當(dāng)value值改變時,同時修改label的字
       proLabel.text( pro.progressbar("value")+"%");
},
     complete:function(){
//當(dāng)進度條完成時,顯示complate
       proLabel.text("Complete!");
}
});

//延遲500毫秒調(diào)用修改value的函數(shù)
   setTimeout( addValue,500);

//動態(tài)修改value的函數(shù)
function addValue(){
var pro = $("#progressbar");
var newValue = pro.progressbar("value")+1;

      pro.progressbar("value",newValue);//設(shè)置新值
if( newValue >=100){return;}//超過100時,返回

      setTimeout( addValue,500);//延遲500毫秒遞歸調(diào)用自己
}
});
</script>
</head>
<body>

<div id="progressbar"><div class="progress-label">Loading...</div></div>

</body>
</html>
(2)截圖
jquery ui(四)進度條 progressbar

progressbar loading的截圖–ifxoxo.com

jquery ui(四)進度條 progressbar

進度條增加value的截圖–ifxoxo.com

jquery ui(四)進度條 progressbar

progressbar 完成的截圖–ifxoxo.com

5、其他

1、事件

(1)create 加載progressbar的時候此事件將被觸發(fā)
(2)change 進度條有改變的時候此事件將被觸發(fā)
(3)complete 加載到100的時候此事件將被觸發(fā)

$('.selector').progressbar({
complete:function(event, ui){ alert('has complete!!');}
});
2、方法

(1) destory 銷毀 .progressbar( “destroy” )
(2) disable 不可用 .progressbar( “disable” )
(3) enable 可用 .progressbar( “enable” )
(4) option 獲取參數(shù) .progressbar( “option”, optionName )
(5) option 設(shè)置參數(shù) .progressbar( “otion” , optionName , [value] )
(6) widget 返回這個element .progressbar( “widget” )
(7) value獲取/設(shè)置value .progressbar( “value” , [value] )

//設(shè)置進度條新值
$("#divProgressbar").progressbar("value",90);

三、其他相關(guān)聯(lián)文章

1、jquery ui(一)簡介
2、jquery ui(二)拖拽 draggable和droppable
3、jquery ui(三)彈出窗口 dialog
4、jquery ui(四)進度條 progressbar
5、jquery ui(五)日期選擇器 datepicker

本文名稱:jqueryui(四)進度條progressbar
URL分享:http://muchs.cn/article46/gecdeg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、外貿(mào)建站營銷型網(wǎng)站建設(shè)、品牌網(wǎng)站建設(shè)網(wǎng)站排名、微信公眾號

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化