我创建了倒计时,这是我的一段代码,但它不起作用,我可能做错了什么?
<div id="container">
<h1 id="time">0:00</h1>
</div>
<script type="text/javascript">
$(document).ready(function(){
var minutes = 1;
var secondsRemaining = minutes * 60;
intervalHandle = setInterval(tick,1000);
function tick(){
var timeDisplay = $('#time');
var min = Math.floor(secondsRemaining / 60);
var sec = secondsRemaining - (min * 60);
if(sec < 0){
sec = "0" + sec;
}
var message = min.toString() + ":" + sec;
timeDisplay.html(message);
if(secondsRemaining === 0){
alert('Done!');
clearInterval(intervalHandle);
resetPage();
}
}
});
</script>
`