I'm creating a function to start a count and when it reaches the final value it stops.
But clearInterval is not working: '(
Has anyone ever had to do something similar?
function numerosHome(){
var inicial = 0;
var location = document.getElementById('participantes');
setInterval(() => {
location.innerHTML = inicial;
inicial++;
if(inicial == 10){
clearInterval();
}
},100);
}
numerosHome()
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script><divclass="numeros" id="participantes">
</div>