I need to \"animate\" a variable with jquery.
Example: The variable value is 1. The value should be 10 after 5 seconds. It should be increase \"smoothl
Use setInterval :
percentage = 0;
startValue = 1;
finishValue = 5;
currentValue = 1;
interval = setInterval(function(){
percentage ++;
currentValue = startValue + ((finishValue - startValue) * percentage) / 100;
doSomething(currentValue);
if (percentage == 100) clearInterval(interval);
}, duration / 100)
function doSomething(val) { /*process value*/}