I have a count down that launches after you click the button. What I’d like to do is have the text and count disappear (“Starting counter here”) after the count of 10 and then change the image from start32.png to stop32.png.
var countdown;
var countdown_number;
function countdown_init() {
countdown_number = 11;
countdown_trigger();
}
function countdown_trigger() {
if(countdown_number > 0) {
countdown_number--;
document.getElementById('countdown_text').innerHTML = countdown_number;
if(countdown_number > 0) {
countdown = setTimeout('countdown_trigger()', 1000);
}
}
}
function countdown_clear() {
clearTimeout(countdown);
}
<body>
<h2>My page</h2>
<table cellpadding="10">
<tr>
<td>Click me</td>
<td><img src = "dashboard/img/start32.png"
title = "Click me"
width = "32"
height = "32"
border = "0"
onclick = "countdown_init()">
</td>
</tr>
</table>
<p>Starting counter here:</p><div id="countdown_text"> </div>
</body>
All you need is an else statement and to set the images src. You can get the image by assigning it an id.
http://jsfiddle.net/6FF3V/1/