Witajcie,
Mam kod JS o zawartości:
<script type="text/javascript">
var Timer;
var TotalSeconds;
var targetDate = "19 February, 2013 07:25:00";
function CreateTimer(TimerID) {
Timer = document.getElementById(TimerID);
todayEpoch = today.getTime();
target
= new Date(targetDate
); targetEpoch = target.getTime();
TotalSeconds = (targetEpoch - todayEpoch)/1000; // get difference and convert to seconds
UpdateTimer()
window.setTimeout("Tick()", 1000);
}
function Tick() {
TotalSeconds -= 1;
UpdateTimer();
if (Math
.floor(TotalSeconds
) <= 0){ window.location.href = "index2.html";
}
else{
window.setTimeout("Tick()", 1000);
}
}
function LeadingZero
(Time) { }
function UpdateTimer() {
var Seconds = TotalSeconds;
var Days
= Math
.floor(Seconds
/ 86400
); Seconds -= Days * 86400;
var Hours
= Math
.floor(Seconds
/ 3600
); Seconds -= Hours * (3600);
var Minutes
= Math
.floor(Seconds
/ 60
); Seconds -= Minutes * (60);
Seconds
= Math
.floor(Seconds
);
var TimeStr = LeadingZero(Days) + " Days " + LeadingZero(Hours) + " hrs " + LeadingZero(Minutes) + " min " + LeadingZero(Seconds) + " sec ";
Timer.innerHTML = TimeStr ;
}
</script>
I na stronie wyświetla się wynik przy użyciu kodu:
<div id='timer'><span id="days">0</li>
<br /><span id="t"> DAYS </span></div>
<script type="text/javascript">window.onload = CreateTimer("timer");</script>
I teraz pojawia się pytanie. Potrzebuję wynik wyświetlić w czterech oddzelnych divach (dni, godziny, minuty, sekundy) i pojęcia nie mam jak to zrobić (ma to być w czystym JS - wiem, że w jQuery to parę linijek kodu). Końcowy efekt ma przypominać coś w stylu
tegoPomocy