Counter Commas

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10022703
    Tomb
    Participant

    Hi Guys,

    Great work!

    Quick question. I am trying to add commas to my counter so for example instead of 1500000 i need it display 1,500,000. Please advise how i can achieve this. i am using the app demo page.

    Thanks Tom


    #10022707
    Support
    Keymaster

    Hello, thanks for your purchase.

    My suggestion is to use the toLocaleString function.

    Example:

    HTML:

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

    JS:

    $('#customCounter').countTo({
        from: 0,
        to: 1500000,
        speed: 1000,
        refreshInterval: 50,
        formatter: function(value, options) {
            return value.toLocaleString();
        }
    });

    Best Regards,

    Jonas


    #10022720
    Tomb
    Participant

    Thank you! works gr8

    The data append however isn’t showing it would need to display 1,500,000 +

    how would i go about sorting this?

    Thanks in advance.

    Kind Regards
    Tom


    #10022728
    Support2
    Keymaster

    Hello Tom,

    In that case you need this code below:
    HTML:

    <strong id="customCounter" data-append="+">0</strong>

    JS:

    $('#customCounter').countTo({
        from: 0,
        to: 1500000,
        speed: 1000,
        refreshInterval: 50,
        formatter: function(value, options) {
            return value.toLocaleString();
        },
        onComplete: function() {
    		if ($(this).data('append')) {
    			$(this).html($(this).html() + $(this).data('append'));
    		}
    
    		if ($(this).data('prepend')) {
    			$(this).html($(this).data('prepend') + $(this).html());
    		}
    	}
    });

    * Note the “onComplete”.

    Please, try that and let me know if you need further assistance.

    Kind Regards,

    Rodrigo.


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

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