<html>
<body>
<a id="haha">5</a>
<script type="text/javascript">
var myVar = setInterval(function(){apa()}, 1000);
var f = 5;
function apa() {
document.getElementById("haha").innerHTML = f;
f--;
apa();
}
</script>
</body>
</html>
I tried to make countdown with timer and decrements, but the output come out not as integer (5, 4, 3, 2, 1,......) but stuffs like -336048 etc instead. How do I fix this?
Should not call
apa()
insideapa
it creates a infinite recursion. ThesetInterval()
will callapa
in 1 sec intervals so no need to call it again.