首页 > 编程技术 > js

jquery实现模拟百分比进度条渐变效果代码

发布时间:2015-10-30 13:43

本文实例讲述了jquery实现模拟百分比进度条渐变效果代码。分享给大家供大家参考,具体如下:

这里为了便于看到加载百分比,对代码进行了处理,实际使用时并不需要这样。

运行效果截图如下:

在线演示地址如下:

http://demo.jb51.net/js/2015/jquery-mn-bfb-scroll-cha-style-demo/

具体代码如下:

<html><head><title>jquery模拟百分比进度条</title><script type='text/javascript'" width=100% 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程序设计有所帮助。

标签:[!--infotagslink--]

您可能感兴趣的文章: