本文實例講述了jquery實現模擬百分比進度條漸變效果代碼。分享給大家供大家參考,具體如下:
這里為了便于看到加載百分比,對代碼進行了處理,實際使用時并不需要這樣。
運行效果截圖如下:

在線演示地址如下:
http://demo.VeVB.COm/js/2015/jquery-mn-bfb-scroll-cha-style-demo/
具體代碼如下:
<html><head><title>jquery模擬百分比進度條</title><script type='text/javascript' src='jquery1.3.2.js'></script><style>#loading{ background:url(bak.png) 0 0 no-repeat; width:397px; height:49px;}#loading div{ background:url(pro.png) 0 0 no-repeat; line-height:49px;height:49px; text-align:right;}</style><script type="text/javascript">var progress_id ="loading";function SetProgress(progress) {if (progress) {$("#" + progress_id +" > div").css("width",String(progress) + "%"); //控制#loading div寬度$("#" + progress_id +"> div").html(String(progress) + "%"); //顯示百分比}}var i = 0;function doProgress() {if (i > 100) {$("#message").html("恭喜您,歌曲上傳成功!").fadeIn("slow");//加載完畢提示return;}if (i <= 100) {setTimeout("doProgress()",500);SetProgress(i);i++;}}$(document).ready(function() {doProgress();});</script></head><body><div id="message"></div><div id="loading"><div></body></html>希望本文所述對大家jQuery程序設計有所幫助。
新聞熱點
疑難解答