Reputation: 697
Please take a look at the code below:
var firstcalenderd = $('div.pmu-instance:eq(0) div.pmu-days div.pmu-button:not(.pmu-not-in-month)').each(function() {
var parsingevents = $('.rko-calendar-event');
parsingevents.each(function() {
if(firstcalenderm == gmonth && currday == gday)
{
.addClass('eventday');
}
});
});
As you can see, there are two .each()
loops , one in another one. If conditions are met in second one (child of first), I want to add class to the first one.
How could I call this parent var?
firstcalenderd.addClass('eventday')
- is not working.
Upvotes: 0
Views: 38
Reputation: 67207
Try to cache it in a variable,
var firstcalenderd = $('div.pmu-instance:eq(0) div.pmu-days div.pmu-button:not(.pmu-not-in-month)').each(function() {
var parsingevents = $('.rko-calendar-event');
var parentVar = $(this);
parsingevents.each(function() {
if(firstcalenderm == gmonth && currday == gday)
{
parentVar.addClass('eventday');
}
});
});
Upvotes: 3