だから私はゼロまでカウントダウンし、ユーザーが続行できるようにdiv内のテキストを切り替えるjavascriptカウントダウンを作成しています。これが私のコードです:
<div id="top">
You will be redirected in 10..
</div>
<script type="text/javascript">
$(document).ready(function(){
var timerId = 0;
if(timerId == 0){
timerId = window.setInterval(function() {
var timeCounter = 10;
var updateTime = parseInt(timeCounter,10) - 1;
$("#top").html("You will be redirected in " + updateTime + "...");
if(updateTime <= 0){
clearTimeout(timerId);
$("#top").html("Click to continue");
}
}, 1000);
}
});
</script>
機能しますが、10 から 9 までしかカウントダウンしません。これはなぜですか?