Hi folks,
How do I get my count-down timer to launch when I press my “Start-Resume” button?
Here is my current Javascript code:
`
//…under experimentation/construction…
$(document).ready(function(){
function startCountDown(){
var seconds = 60;
function secondsPassed(){
//inside this function, new variable called minutes
var minutes = Math.round((seconds-30)/60);
//now going to add another variable inside function for remaining seconds
var remainingSeconds = seconds % 60;
if (remainingSeconds < 10){
remainingSeconds = "0" + remainingSeconds;
}
//Output the result in an element with id="number"
document.getElementById('number').innerHTML = minutes + ":" + remainingSeconds
//once remaining seconds reach none, interval is over so write some text
if( seconds == 0){
clearInterval("number");
document.getElementById("number").innerHTML= 'Buzz!!'; //temporary placeholder....will link to a buzz sound later
}else{
seconds--; //decrements
}
}
var number = setInterval('secondsPassed()', 1000);
$(".start-resume").click(function(){
startCountDown();
});
}
$('.start-resume').click(function(){
$('#number').addClass("on");
});
});
`
Here is a link to my jsfiddle: https://jsfiddle.net/MenelikMakonnen/230xtgmb/5/
Thanks in advance for your help! Cheers!