Skip to content
Sign upLog in
← Back to Community

how do you show your cps in html

Profile icon
RyanCheung1

I am trying to complete a money clicker game, the last thing I need to complete is a cps tracker to show the clicks per second. pls give me the code to be able to do this

Voters
Profile icon
BraxtonElliott
Profile icon
GeoGamer09
Profile icon
stuGabrielVan
Profile icon
RyanCheung1
Comments
hotnewtop
Profile icon
InvisibleOne
<h4>Clicks Per Second: <span id='clickPerSec'></span><h4>

in the JS

cps = 1; document.getElementById('clickPerSec').innerHTML = cps; setInterval(function(){ clicks += cps; }, 1000) // this function will run once every second.
Profile icon
RyanCheung1

@InvisibleOne
even though this works, it doesn't show the cps counter

Profile icon
InvisibleOne

wdym? Do you want it to display how many clicks per second you have, or did you want something else?

@RyanCheung1

Profile icon
InvisibleOne

You mean update the score each time? add this inside of thesetInterval function.

document.getElementById('moneyValue').innerHTML = clicks; // do the same for the lifetime Money

@RyanCheung1

Profile icon
RyanCheung1

@InvisibleOne
I want to display how many clicks per second I have

Profile icon
RyanCheung1

@InvisibleOne
it doesn't update the clicks per second