Implementing a feature that displays statistics by incrementing rapidly until reaching their final value when the element is in view, creating the illusion of a rising number.
Encountering some difficulty in passing the necessary parameters to identify the element to be incremented and determine the final value for determining when to stop the incrementation process.
function increaseValue(elem, finalNum) {
var currentNum = parseInt(document.getElementById(elem).innerHTML, 10);
if (currentNum < finalNum) {
currentNum++;
document.getElementById(elem).innerHTML = currentNum + "%";
setTimeout(function() {
increaseValue(elem, finalNum);
}, 40);
}
};
For a comprehensive view, visit the following CodePen link: http://codepen.io/BAWKdesign/pen/yePOGV