I have a list of elements with the same class month
. Some of them might have the class cal
as well, and only one element of the list has the class today
.
I'd like to search for the first element with the class cal
, but only after the element today
is found. The tricky part here is that the elements might not be siblings. If they were siblings, this would work:
$('#eventCal .today').nextAll('#eventCal .cal:first').text();
So for example, if I have the following list, how could I target the first cal
after today
?
<div id="eventCal">
<ul>
<li class="month"></li>
<li class="month cal">Not show because it's before TODAY</li>
<li class="month"></li>
</ul>
<ul>
<li class="month"></li>
<li class="month today">Today</li>
<li class="month"></li>
</ul>
<ul>
<li class="month cal">To show as it's the first CAL after the TODAY</li>
<li class="month cal">Not show because is not the first CAL</li>
<li class="month"></li>
</ul>
</div>