I am to invoke a timer using the click of a button. Function for timer:
function countDown(seconds, elem){
var element = document.getElementById(elem);
element.innerHTML = "Please wait for "+seconds+ " seconds";
if(seconds < 1){
clearTimeout(timer);
element.innerHTML ='<h2> You can let Go, Frist Responders have been informed</h2>';
}
seconds--;
var timer = setTimeout('countDown('+seconds+',"'+elem+'")',1000);
}
Function call:
document.querySelector('body').onClick = countDown(5,"para");
HTML:
<div class="wrapper" id="butt2">
<button id="butt" class="fade-in-fwd" >SOS</button>
</div>
<p id="para"></p>
This starts running the timer as soon as the webpage loads. How do I limit this