js loading percent

<div class="loading-percent"><span>100</span>%</div>
<script type="text/javascript">
	//loading and fadeIn
	jQuery(document).ready(function($){
		function count($this){
			var current = parseInt($this.html(), 10);
			$this.html(++current);
			if(current !== $this.data('count')){
				setTimeout(function(){count($this)}, 50);
			} else {
				$("#loading").hide();
			    $("#loading").next().fadeIn();
			}
		}
		$(".loading-percent span").each(function() {
			$(this).data('count', parseInt($(this).html(), 10));
			$(this).html('0');
			count($(this));
		});
	})
</script>

参考页面:http://jsfiddle.net/WpJxn/1/

514 total views, 2 views today

Revisions

There are no revisions for this post.

No comments yet.

发表评论