$(document).ready(function() { $('.stat-count-to').each(function () { let self = $(this) let data = self.data('value'); $(this).prop('Counter', 0).animate( { Counter: parseInt( data.toString().replace(/[_\W]+/g, '') ), }, { duration: 3000, easing: 'linear', step: function (now) { $(this).text(Math.ceil(now).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')); }, } ); }); });