私はカウントダウンのこの種のやろうとしています:単純な時間のカウントダウン
は、今では午前9時20分であると私は1時間に残っているどのように多くの分と秒たい思いを。だから、10分に40分かかります。
このカウントダウンは、このギャップを1日以内に継続的にカウントする必要があります。
私は次のことを試してみたが、それはうまくいきませんでした:
var now = new Date();
var mins = now.getMinutes();
var secs = now.getSeconds();
function initClock(id) {
const counter = document.getElementById(id);
const minutesItem = counter.querySelector('.js-countdown-minutes');
const secondsItem = counter.querySelector('.js-countdown-seconds');
function updateClock() {
mins = now.getMinutes();
secs = now.getSeconds();
minutesItem.innerHTML = (60 - mins);
secondsItem.innerHTML = (secs);
}
updateClock();
const timeinterval = setInterval(updateClock, 1000);
}
initClock('js-countdown');
秒が更新されていません。
plsもhtmlを共有しています。 –
_itがうまくいかないと言うと、何がうまくいかないと言うのが良いです – George
[日付、時間、分、秒を読み取るプログラムを作るにはどうすればいいですか? 2番目の日付から減算する](https://stackoverflow.com/questions/46973205/how-can-i-make-a-program-that-reads-the-datehour-minutes-seconds-then-it-subtr) – RensvWalstijn