bfintal / Counter-Up

Counter-Up is a lightweight jQuery plugin that counts up to a targeted number when the number becomes visible.
http://bfintal.github.io/Counter-Up/demo/demo.html
GNU General Public License v2.0
746 stars 722 forks source link

Allow percent in the count #33

Open RosiersRobin opened 8 years ago

RosiersRobin commented 8 years ago

Hi,

I want to be able to have a percentage in the count like

25%

If I add percent now, I got NaN

goodwinpress commented 8 years ago

hi! try % instead %

RosiersRobin commented 8 years ago

Doesn't work either. Isn't there a possibility to change the HEX thing? Like s = /[0-9]+,[0-9]+/.test(i); doesn't allow chars....

There must be a solution for this?

brycekirk commented 8 years ago

Im using the :after pseudo-selector and it works quite well.

<span class="counter" id="your-number">24.1</span>

#your-number:after { content: "%"; }

speedygonzales77 commented 5 years ago

Hi all,

In my case I can't do the code shared below by brycekirk because I'm using multiple numbers like.

1,943 register 90% increase.

and the result would be 1,943% wouldn't it?

your-number:after { content: "%"; }

speedygonzales77 commented 5 years ago

Well, I ended up using brycekirk suggestion after all. I just had to do some weird tweaks.

`

                        ## RAUL - 11-16-2018 had to do some tweaks to make anything with a percent sign remove it first, then run the counter program then add the percent sign again.
                        #if($_EscapeTool.xml($fact.getChild("heading").value).contains("%"))
                        #set($per_val = $_EscapeTool.xml($fact.getChild("heading").value))
                        #set($rep_per_val = $per_val.replace("%", "") )
                            <p class="fact-row-stat counter" id="your-number" style="color: #ed9f13;">$rep_per_val</p>
                            <style>#your-number:after { content: "%"; }</style>
                        #else
                            <p class="fact-row-stat counter" style="color: #ed9f13;">$_EscapeTool.xml($fact.getChild("heading").value)</p>
                        #end

`

huphtur commented 5 years ago

Why not simply put the % outside the .counter span?

<span class="counter">1,953</span> register
<span class="counter">90</span>% increase