I want that when i click a button, the percentage of the div go very fast from 0 to the number of the div. How can I implement the animation to my code?
JSFiddle: https://jsfiddle.net/252jxsjq/5/
jQuery:
var counter = localStorage.getItem('rans') || 0;
var counter = Number(localStorage.getItem('rans')) || 0;
var counter1 = Number(localStorage.getItem('bans')) || 0;
$('.redanswer').click(function(){
localStorage.setItem('rans', ++counter);
$( '.bpercent' ).html( counter1 * 100 / (counter1+counter) + "%" );
$( '.rpercent' ).html( counter * 100 / (counter1+counter) + "%" );
$('.rpercent').animateNumber({ number: 'rans' });
});
var counter1 = localStorage.getItem('bans') || 0;
var counter = Number(localStorage.getItem('rans')) || 0;
var counter1 = Number(localStorage.getItem('bans')) || 0;
$('.blueanswer').click(function(){
localStorage.setItem('bans', ++counter1);
$( '.rpercent' ).text( counter * 100 / (counter1+counter) + "%" );
$( '.bpercent' ).text( counter1 * 100 / (counter1+counter) + "%" );
});