-3
I have an agenda I want you to hide when every day of the week is closed. So I did this function that analyzes if the content of the day is Closed and if all 7 days have Closed it hides the agenda.
$( document ).ready(function() {
var statusClosed = $('.agenda-status').html();
if (statusClosed === 'Fechado') {
$('.agenda-dia').addClass('dia-fechado');
var semanaFechada = $('.agenda-semanal .dia-fechado').length;
if( semanaFechada >= 7 ) {
$('.agenda-semanal').addClass('semana-fechada');
$('.semana-fechada').hide();
}
}
});
It turns out that when every day of the agenda is closed it works, but if the first day is open it does not perform the function. I believe it is on account of . html() only do the search on the first element.
How do I search for all elements ". agenda-status" and not only in the first?
<li class="agenda-dia ">
<a href="javascript:;" data-type="Fechado">
<span class="dia-semana Domingo">Domingo</span>
<em class="agenda-status">Fechado</em>
</a></li>
Do you intend to hide your own schedule when the day is closed? I recommend that you post your question in Portuguese, so that it is more easily understood. : p
– Paulo Martins
Paulo, I put in Portuguese =), thank you. I intend to hide the agenda when every day (7) have the contents of the div <em class="agenda-status">Closed</em> Closed.
– virginiarcrz
Can you describe better how these agendas were structured? Is it an agenda made with exactly 7 days? There are other weekly agendas on the page?
– Paulo Martins