Skip to content

Comma formatter for external js file #71

@originalorange

Description

@originalorange

Apologies, I know you've been over this many times, but I can't seem to find an example like mine. I am using an external js file to call countTo which pulls the "to" value from the html (.count-number). I am trying to include the custom formatter to add the commas but I can't get it to work. Here is what I currently have:

function initCounters(){
$(".count-number").appear(function(){
var count = $(this);
count.countTo({
from: 0,
to: count.html(),
speed: 1300,
refreshInterval: 60,
formatter: function (value, options) {
value = value.toFixed(options.decimals);
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return value;
}
});
});
}

What am I doing wrong? Needless to say I am a total novice and appreciate any assistance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions