<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
var _totalJackpot = $('#gameTicker').text();/*获取网页中的值*/
var _startsum = Math.round((_totalJackpot * 0.9995) * 100) / 100;
var _offset = _totalJackpot - _startsum; /*两者之间的差值,没什么用*/
//调用函数,期望实现动画效果,为什么不行呢?
function wajticker(_jstart, _jtotal) {
var jstarts;
if (_jstart < _jtotal) { var jstarts = _jstart + 0.01;
}
else {
jstarts = Math.round((_jtotal * 0.9995) * 100) / 100;
}
var displayVal = addCommas(Math.abs(Math.round(_jstart * 100) / 100));
$('#sicTick').text('$' + displayVal);
setTimeout(function () { wajticker(jstarts, _jtotal); }, 500);
} function addCommas(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
// setInterval(wajticker(_startsum, _totalJackpot), 500);
wajticker(_startsum, _totalJackpot);
});
</script>
</head>
<body>
<div id="sicTick">
</div>
<div id="gameTicker" style="">11482710.20</div>
</body>
</html>试试吧,不知道是不是你要的结果
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
var _totalJackpot = $('#gameTicker').text();/*获取网页中的值*/
var _startsum = Math.round((_totalJackpot * 0.9995) * 100) / 100;
var _offset = _totalJackpot - _startsum; /*两者之间的差值,没什么用*/
//调用函数,期望实现动画效果,为什么不行呢?
function wajticker(_jstart, _jtotal) {
var jstarts;
if (_jstart < _jtotal) { var jstarts = _jstart + 0.01;
}
else {
jstarts = Math.round((_jtotal * 0.9995) * 100) / 100;
}
var displayVal = addCommas(Math.abs(Math.round(_jstart * 100) / 100));
$('#sicTick').text('$' + displayVal);
setTimeout(function () { wajticker(jstarts, _jtotal); }, 500);
} function addCommas(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
// setInterval(wajticker(_startsum, _totalJackpot), 500);
wajticker(_startsum, _totalJackpot);
});
</script>
</head>
<body>
<div id="sicTick">
</div>
<div id="gameTicker" style="">11482710.20</div>
</body>
</html>试试吧,不知道是不是你要的结果
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货