Please tell me how to write a condition, if all the list divs have display: none then do something, and if not all, do nothing. Now we have the following code:

<div class="line_table"> <div> </div> <div> </div> <div> </div> </div> 

When you click on the button, there is a search for words for a match, and to those div, which did not find a match by words, assigns style: diplay: none. I wrote this script here:

  $(".bottom_line_table > div").each(function() { if ($(this).css("display") == "none") { $('.not_found_table').fadeIn('slow'); } else { } }); 

But it always works, even if there is a div in the list, with display: block.

  • because you call fadeIn when you find the first hidden hidden Grundy
  • Do not tell me, but how to write a condition, what would fadeIn be called if all divs are hidden? - Denis Yaroshinsky

1 answer 1

To check that everything is invisible, you need to take all, select those that are invisible and compare the quantity.

 var all = $(".bottom_line_table > div"); var hidden = all.filter(function(){ return ($(this).css("display") == "none"); }) if (all.length == hidden.length){ // выполняем нужные действия }