いいえ。私は別のspan
を持っていて、そのid
属性をY-m-d形式の日付に設定しています。私は各スパンのカウントダウンを計算するためにカウントダウンjsを使用していますが、私の関数は1つの日付を選択し、それにカウントダウンを適用します。他の日付のカウントダウンは評価されません。jqueryですべての要素を読み込む方法
<span class="timer" id="2017-10-1"></span>
<span class="timer" id="2017-10-2"></span>
<span class="timer" id="2017-10-3"></span>
<span class="timer" id="2017-10-4"></span>
これはカウントダウンjqueryの
http://hilios.github.io/jQuery.countdown/
と私は関数の中で書いています。
$(document).ready(function() {
var time = $(".timer").attr('id');
var timeLeft = time.split('-').reverse().join('-');
$(".timer").countdown(timeLeft, function (event) {
$(this).text(event.strftime("%D days %H hours %M minutes %S seconds remaining"));
});
});
おそらくまた*理由を説明します*。 –
これは機能します! – Matt
私はむしろ、ループの外側にtimeとtimeLeft変数を宣言したいが、コードは完璧である。 – avilac