마크업 부분

1
2
3
4
<script src="https://code.jquery.com/jquery-1.7.0.min.js"></script>
<script src="https://aishek.github.io/jquery-animateNumber/javascripts/jquery.animateNumber.js"></script>
 
<p id="decimals">From $0,00 to $5000,00</p>
cs


스크립트 부분

1
2
3
4
5
6
7
8
9
10
11
12
$('#decimals')
  .animateNumber(
    {
      number: 2500,
      numberStep: function(now, tween) {
        // see http://stackoverflow.com/a/14428340
        var formatted = now.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
        $(tween.elem).text('$' + formatted);
      }
    },
    20000
  );
cs

참고 : http://stackoverflow.com/a/14428340

+ Recent posts