Using JQuery replaceWith with a JavaScript Variable
Posted
by
JJ56
on Stack Overflow
See other posts from Stack Overflow
or by JJ56
Published on 2011-02-12T07:11:51Z
Indexed on
2011/02/12
7:25 UTC
Read the original article
Hit count: 208
Here's my html:
<div class="timer">Not Started</div>
And JS/JQ:
var seconds = 10;
var minutes = 0;
setTimeout("updateTimer()", 1000);
function updateTimer() {
if (seconds == 0 && minutes != 0) {
minutes -= minutes;
seconds = 59;
alert (seconds);
} else if (seconds == 1 && minutes == 0) {
alert ('done');
} else {
seconds = seconds - 1;
//alert (seconds);
$(".timer").replaceWith(seconds);
}
setTimeout("updateTimer()", 1000);
}
Instead of replacing Not Started with 10, 9, 8..., Not Started disappears.
© Stack Overflow or respective owner