npm install simple-odometer
import "simple-odometer/src/js/odometer.js";
import "simple-odometer/src/css/odometer.css";
<link rel="stylesheet" href="simple-odometer/src/js/odometer.css">
<script src="simple-odometer/src/js/odometer.js"></script>
<span id="odometer">0</span>
<button id='animate'>Animate</button>
window.odometerOptions = { format: '(,ddd).dd', duration: 2000, }
const button = document.querySelector('#animate'); button.onclick = () => { // Target the element to animate const target_elem = document.querySelector('#odometer'); // Create na instance const OdoInstance = new Odometer({ // pass the element ref el: target_elem, // Old value to animate from value: target_elem.innerHTML }); // Finally, give it a new value to animate to OdoInstance.update(Math.random() * 1000); // new value }