javascript - Show headers only for collections that are not empty -


i have couple of lists this:

<ul> <li class="list-header">header</li> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> 

by rules hide , show <li> items list has visible <li> , has no visible <li> elements @ except 1 list-header class, <li class="list-header"> still there. want hide header if there no <li> visible elements in under header. though want <ul> still visible. how do that?

what could (demo):

$('ul').each(function() {     $ul = $(this);     $ul.find('.list-header').toggle($ul.has('li:not(.list-header):visible').length != 0); }); 

basically, above toggling .list-header (i've wrapped in .each() in order demo different lists) depending on whether list .has() :visible li elements :not(.list-header).

update
works. sorry.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -