jQuery('document').ready(function($){ const counters = document.querySelectorAll('.groupeAG__decompte--item'); const speed = 200; counters.forEach( counter => { const animate = () => { const value = +counter.children[0].dataset.endValue; const data = +counter.children[0].innerText; const time = value / speed; if(data < value) { counter.children[0].innerText = Math.ceil(data + time); setTimeout(animate, 1); }else{ counter.children[0].innerText = value; } } animate(); }); //end document ready });