I have the following jQuery code. The this.Next() function is throwing a "is not a function" error when called. The this.Next() function is called within the same function as this.countdown(). How would I call this.Next() inside the setInterval() nested function?
this.countdown = function(element) {
interval = setInterval(function() {
var el = document.getElementById(element);
if(seconds == 0) {
if(minutes == 0) {
alert(el.innerHTML = "Your time for this section has expired");
clearInterval(interval);
// Send user to the next section
return this.Next();
} else {
minutes--;
seconds = 60;
}
}
if(minutes > 0) {
var minute_text = minutes + ' min';
} else {
var minute_text = '';
}
var second_text = 'sec';
el.innerHTML = 'Your time: ' + minute_text + ' ' + seconds + ' ' + second_text;
seconds--;
}, 1000);
};