简体   繁体   中英

How can I make a "live" counter in HTML?

I am doing a project on the CO2 emissions of datacenters and want to incorporate my essay into a website with visuals. How could I go about creating a counter that counts up and adds a little image every time the counter goes up? Kind of like this website: https://www.internetlivestats.com/watch/co2-emissions/ - My skill level is still pretty beginner if that helps.

First add more details of your question otherwise someone will downvote your question. Secondly for your question part you can use setInterval() or setTimout() check out documentation https://www.w3schools.com/jsref/met_win_setinterval.asp

var count=0;
setInterval(()=>{
count++;
 //your logic here
},1000)//it will increment counter after 1 second you can change

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM