I have the following javascript code:
// timer code
var count=120;
var pars = 0;
var counter=setInterval(timer, 1000); // will run it every 1 second
var redirect="index.php";
function timer(){
if (count <= 0){
window.location = redirect;
} else{
if(pars == 1){
} else {
count=count-1;
}
}
document.getElementById("timer").innerHTML=":" + count ;
}
which displays a timer in div#timer, and I need it to have a pause on some link click as follow:
$(".quad").click(function(){
pars = 1;
});
As I am new to javascript, I think this problem is cause by global & private variables. Can you help me please?