I'm trying to detect wether there is .product which css is display: block; (visible) in .calendar-paper or not.
var $objArr = $('.calendar-paper');
$objArr.each(function(i) {
var $thisCalendar = $objArr.eq(i);
if(!$thisCalendar.find('.product').filter(':visible')) {
// Do something if the content of .calnedar-paper is empty
} else {
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="calendar-paper">
<div class="product" style="display: block;">...</div>
<div class="product" style="display: none;">...</div>
</div>
<div class="calendar-paper">
<div class="product" style="display: block;">...</div>
</div>
And the result shows that even if the .product css display: none, still run the else condition. That's not what I expect. Please explain to me where the logic goes wrong. Thank you.