'Decimals in countUp.js

I am using the countUp javascript library and I am trying to get decimals to work but it doesn't seem to. The code:

<body>
<div>Total birds:</div>
<div id="myTargetElement" class="numberCircle"> </div>

<script>
 var demo = new CountUp("myTargetElement", 0, 256.59, 0, 2.5,{decimals:2,prefix:'$'});
 demo.start(); //result: $257
</script>
</body>


Solution 1:[1]

Its decimal not decimals

var demo = new CountUp("myTargetElement", 0, 256.59, 0, 2.5,{decimal:2,prefix:'$'});
demo.start(); //result: $257

if above didnt work try wrapping your call inside jquery is ready function

$(function(){
    //code
});

Solution 2:[2]

for the vuejs Wrapper vue-countup-v2 just add decimalPlaces as part of the options object i.e options: { decimalPlaces:3 }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Victor Raji