<!DOCTYPE HTML>
<html lang="zh_CN">
<head>
<meta charset="UTF-8">
<title>数字动态效果</title>
<style type="text/css">
.MJHmain .MJHsimpleInfo { padding: 78px 0; text-align: center; color: #939698;}
.MJHmain .MJHsimpleInfo li{ float: left; width: 331px; margin-top: 30px;}
p{width:600px; font-size: 16px; margin-top: 13px; text-align: right;}
</style>
</head>
<body>
<div id="wrap">
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<div class="MJHsimpleInfo">
<ul class="clearfix">
<li><p><em class="fangan">41,987</em>套</p>
<p>出行方案</p>
</li>
<li><p><em class="luxian">45,880,873</em>套</p>
<p>飞行路线</p>
</li>
<li><p><em class="jiudian">22,682,856</em>套</p>
<p>酒店方案</p>
</li>
</ul>
</div>
</body>
<script type="text/javascript">
$(function(){
jishi($(".fangan"),61987,280,140);
jishi($(".luxian"),47880873,216281,108141);
jishi($(".jiudian"),24682856,111494,55747);
})
function commafy(n){
n = n + "";
var re = /(-?\d+)(\d{3})/;
while (re.test(n)) {
n = n.replace(re, "$1,$2");
}
return n;
}
function jishi(ele,numOri,n1,n2){
var i=0;
var plusNum=parseInt(Math.random()*(n1-n2+1)+n2);
setInterval(function(){
i=i+plusNum;
if(i<=numOri){
ele.text(commafy(i));
}else if(i>numOri){
ele.text(commafy(numOri));
}
},10)
tag=false;
}
</script>
</html>