Format numbers javascript counters

Home Forums Porto – Responsive HTML5 Template Format numbers javascript counters

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10005137
    stevenagy88
    Participant

    Hi,

    When using javascript counters, such as on the about page of your Porto theme, we would like to format the numbers according to locale settings. How would we go about this?

    Thanks,
    Steve Nagy


    #10005164
    Support
    Keymaster

    Hello, you can change the “formatter” function and set “decimals”, like this:

    HTML:

    <strong id="myCounter">0</strong>

    JS (js/custom.js)

    $('#myCounter').countTo({
    	from: 50,
    	to: 2500,
    	speed: 1000,
    	decimals: 2,
    	refreshInterval: 50,
    	formatter: function (value, options) {
    		return value.toFixed(options.decimals);
    	},
    	onUpdate: function (value) {
    		
    	},
    	onComplete: function (value) {
    		
    	}
    });

    Let me know if you need further assistance.

    Kind Regards, Jonas


Viewing 2 posts - 1 through 2 (of 2 total)

This topic is marked as "RESOLVED" and can not rceive new replies.