numbers counting up css

//HTML
<div id="value">100</div>

//CSS
div {
  font: 800 40px system-ui;
}

//JavaScript
function animateValue(obj, start, end, duration) {
  let startTimestamp = null;
  const step = (timestamp) => {
    if (!startTimestamp) startTimestamp = timestamp;
    const progress = Math.min((timestamp - startTimestamp) / duration, 1);
    obj.innerHTML = Math.floor(progress * (end - start) + start);
    if (progress < 1) {
      window.requestAnimationFrame(step);
    }
  };
  window.requestAnimationFrame(step);
}

const obj = document.getElementById("value");
animateValue(obj, 100, 0, 5000);

4.14
7
Mitch M 70 points

                                    function animateValue(obj, start, end, duration) {
  let startTimestamp = null;
  const step = (timestamp) =&gt; {
    if (!startTimestamp) startTimestamp = timestamp;
    const progress = Math.min((timestamp - startTimestamp) / duration, 1);
    obj.innerHTML = Math.floor(progress * (end - start) + start);
    if (progress &lt; 1) {
      window.requestAnimationFrame(step);
    }
  };
  window.requestAnimationFrame(step);
}

const obj = document.getElementById(&quot;value&quot;);
animateValue(obj, 0, 1220, 5000);

const obj2 = document.getElementById(&quot;value2&quot;);
animateValue(obj2, 0, 520, 5000);

4.14 (7 Votes)
0
3
2
Ericn 95 points

                                    //HTML
&lt;div id=&quot;value&quot;&gt;100&lt;/div&gt;

//CSS
div {
  font: 800 40px system-ui;
}

//JavaScript
function animateValue(obj, start, end, duration) {
  let startTimestamp = null;
  const step = (timestamp) =&gt; {
    if (!startTimestamp) startTimestamp = timestamp;
    const progress = Math.min((timestamp - startTimestamp) / duration, 1);
    obj.innerHTML = Math.floor(progress * (end - start) + start);
    if (progress &lt; 1) {
      window.requestAnimationFrame(step);
    }
  };
  window.requestAnimationFrame(step);
}

const obj = document.getElementById(&quot;value&quot;);
animateValue(obj, 100, 0, 5000);

3 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
number counter form html html number counter exapmles counter number html number counter input html show nubmer counter in html how to make number counter in html html input number counter html counter number element number counter html css how to make number counter up in html html counter number number counting html numbers count html how to use counter number in html html number counter demo counter number javascript create a number counting up animation css js html css js counter animated number counter html css rotating numbers CSS Numbers from 1 to 10 html crandom counters animated counter counter effect css js counter animation auto number increase animation css numbers change animation creating Number from 1 to 100 using html and css css number counter number change animation javascript counter animation in css css number change animation js numbers counter animate number javascript function how to show counting number animation with js animation with numbers js number moving up animation js number increasing animation js number counter in html free html increase number effect number increase animation running numbers js simple js animated counter how to make a number counter in html counter number in html animated number js number update animation number animation js number animation counter javascript animation during counter running by js counter animate counter number css animate counters css transition numbers animated number counter count animation javascript counter in html simple counter with css animation css counter animation generator is animate.css count in bootsrap or css is animate.css count in bootsrap orcss javascript number counter animation js animate number increase counter animation number rolling animation css css increasing number animation counting effect css js animate number change live counting numbers html javascript counter animation Js number animation css transition animation of numbers number effects css number increase animation javascript css number count up animation how to animate numbers in javascript count number html counter number increasing html css number animation counter javascript counter number css count animation html counter box counting numbers html css numbers counting up css animate number counter javascript animate number with css animate decimal numbers css number efict in css javascript css smooth counting number css number counter animation animated counter numbers for website animated numbers js html animate number increase css animation number increment effect number animation css how to create a number counter with css animationn counter search mnumber counter html animation number css animation number count number animation css counter animation number counter html
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source