Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding span around each number #29

Open
vaclavgreif opened this issue Oct 30, 2014 · 1 comment
Open

Adding span around each number #29

vaclavgreif opened this issue Oct 30, 2014 · 1 comment

Comments

@vaclavgreif
Copy link

Hi, I'm trying to add a span around each number to be able to format each number differently.
formatter: function (value, options) { var value = value.toFixed(options.decimals); return value.replace (/(<.*?>)|(.)/g, function (m0, tag, ch) { return tag || ('<span>' + ch + '</span>'); }); }

I tried to use this formatter function, which works, but ouptuts the tag so they get displayed, instead as HTML. Is there a way to fix this?

@mhuggins
Copy link
Owner

Ahh, yeah, it was changed from the html function to the text function in this pull request. I suppose for handling both use cases, it would make sense to allow something like a renderWith option (defaults to 'text' but allows 'html' or any other valid jQuery function). Then you could just call via:

$('.timer').countTo({ renderWith: 'html' });

...or via HTML data attributes:

<span class="timer" data-render-with="html" data-from="0" data-to="100"></span>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants