JS로 매우 기본적인 것을 수행하려고합니다. 숨겨진 태그에서 남은 초의 양을 가져온 다음이 태그를 파싱하는 카운트 다운이 있습니다. 함수의 끝에서 span 태그의 초 단위로 간격 타이머를 제거하려고합니다. 이 순간 내가 행한 :자바 스크립트 기본 수학
parseInt($(this).find("#sqbTimestamp").text()) - 3;
나는 다음의 setTimeout을 사용 (기능, 2) (그것을 처리하는 초 여유를 줄) 그것을 2 초마다 실행합니다. 그러나 위의 계산에서 콘솔 로그로 출력 된 숫자는 함수를 실행할 때마다 동일합니다. 스팬 컨테이너 초
function countdownProcedure(){
var interval = 10000;
var i = 0;
var seconds = null;
console.log(C++)
$(".rfqTbl tr").each(function(){
if(i > 0){
seconds = $(this).find("#sqbTimestamp").text();
var tsInt = parseInt($(this).find("#sqbTimestamp").text());
var days = Math.floor(seconds/(60*60*24));
seconds -= days * 60 * 60 * 24;
var hours = Math.floor(seconds/(60*60));
seconds -= hours * 60 * 60;
var minutes = Math.floor(seconds/60);
seconds -= minutes * 60;
//$(this).find("#sqlTimestamp").text(newTS);
console.log(tsInt - 3);
if(days < 1){ days=""; }
$(this).find("#countDown").html(days + "<pre> Days</pre> " + hours + "<pre>:</pre>" + minutes + "<pre>:</pre>" + seconds);
$(this).find("#countDown").append(i + " - " + seconds);
if(days > 1){
$(this).find("#countDown").css({
'color':'#2A7F15',
'font-weight':'bold'
});
};
if(days < 1){
$(this).find('#countDown').css('color','red');
$(this).find('#countDown pre:nth-of-type(1)').css('display','none');
}
if(seconds < 10){ $(this).find("#countDown").append(" "); };
if(minutes < 60){ interval = 1000; };
}
i++;
});
setTimeout(countdownProcedure,interval);
};
'setTimeout'은 초가 아니라 * 밀리 초 *입니다. – Bergi
#sqbTimestamp 텍스트를 업데이트하지 않으므로 log (tsInt - 3)는 항상 동일합니다. – elnabo
"* 함수 끝에서 span 태그에서 초 단위로 간격 타이머를 제거하고 싶습니다. *"- 아무데도 보이지 않습니까? – Bergi