Can someone assist me. below is a snippet of code and getting issue with. inside of the each function the "this" returns all the child elements of ".countdown-timer", which is what I expect it to be. However, inside of the setInterval() function the value of "this" is window object. I would like to know as to why this is the case.
$(function(){
$('.countdown-timer').each(function(){
console.log(this);
if(this.dataset.enddate){
$(this).append(timercontent);
var data =this.dataset.enddate.split('-');
setInterval(function() {
console.log(this);
if (distance < 0) {
clearInterval(x);
$(".countdown-timer").append('<h3>Expired!</h3>')
}
}, 1000);
}
})
})