The screenshot of the timer 私はソフトウェアで作業していますが、タイマーが終了したらボタンを無効にしたいと思います。タイマーは追加されましたが、タイマーの終了後にボタンを非表示にすることはできません。10分タイマーを開始する方法と、JavaScriptを使用してタイマーの後にボタンを無効にする方法
以下は、タイマーのhtmlです。
<div class="form-group">
<label for="name" class="cols-sm-2 control-label">If you want to cancel the hiring you can <br /> Time remaining <span id="time"></span> minutes! </label>
</div>
<div class="form-group ">
<input type="submit" id="btnCancel" name="btnCancel" value="Cancel " class="btn btn-success btn-lg btn-block login-button" />
</div>
以下は、タイマーのjavascriptです。
<script>
function startTimer(duration, display) {
var start = Date.now(),
diff,
minutes,
seconds;
function timer() {
// get the number of seconds that have elapsed since
// startTimer() was called
diff = duration - (((Date.now() - start)/1000) | 0);
// does the same job as parseInt truncates the float
minutes = (diff/60) | 0;
seconds = (diff % 60) | 0;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = minutes + ":" + seconds;
if (diff <= 0) {
// add one second so that the count down starts at the full duration
// example 05:00 not 04:59
start = Date.now() + 1000;
}
};
// we don't want to wait a full second before the timer starts
timer();
setInterval(timer, 1000);
}
window.onload = function() {
var tenMinutes = 60 * 10,
display = document.querySelector('#time');
startTimer(tenMinutes, display);
};
</script>
あなたがしようとしたものを私たちに見せて動作していない、具体的内容を説明。 – csmckelvey
「