jQuery實現的進度條效果,jquery實現進度條

來源:互聯網
上載者:User

jQuery實現的進度條效果,jquery實現進度條

在某些特定的情境下,應用進度條效果,可以提高網站的人性化程度,能夠讓使用者能夠掌握進度,增加對進度的耐心,否則可能直接導致關閉頁面,從來導致網站流失使用者,下面就是用過jQuery實現的進度效果代碼。

<!DOCTYPE html><html><head><meta charset="utf-8"><title>幫客之家</title><script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script><style type="text/css">#progress { background:white; height:20px; padding:2px; border:1px solid green; margin:2px;}#progress span { background:green; height:16px; text-align:center; padding:1px; margin:1px; display:block; color:yellow; font-weight:bold; font-size:14px; width:0%;}</style><script type="text/javascript">  var progress_node_id = "progress";  function SetProgress(progress) {   if (progress) {    $("#" + progress_node_id + " > span").css("width", String(progress) + "%");    $("#" + progress_node_id + " > span").html(String(progress) + "%");   }  }  var i = 0;  function doProgress() {  if (i > 100) {   alert("Progress Bar Finished!");   return;  }  if (i <= 100) {   setTimeout("doProgress()", 500);   SetProgress(i);   i++;  }  }  $(document).ready(function() {   doProgress();  }); </script></head><body><h1>jQuery實現進度條效果代碼</h1><p>原理就是使用 Javascript 控制 SPAN CSS 的寬度(以及其他的樣式),重新整理查看</p><div id="progress"><span></span></div></body></html>

以上代碼實現了常用的進度條效果,在進度條推進的時候有百分比標註,非常的人性化。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.