function countDown(secs,elem)
{
var element = document.getElementById(elem);
element.innerHTML = "Game ends in " + secs + " seconds!";
if(secs<1)
{
clearTimeout(timer);
document.getElementById('gameContent').style.display='none';
}
secs--;
var timer = setTimeout('countDown('+secs+',"'+elem+'")',1000);
}
<div class="timerCount" id="status"></div>
<script>countDown(5,"status");</script>
我的计时器在 5 秒后正确启动并递减。我的游戏 div 在计时器达到 0 后隐藏,但计时器没有清除并结束,而是变为负数。请我的代码中的错误,以便停止计时器并清除它