javascript prototype problem

Posted by Chris Tosswill on Stack Overflow See other posts from Stack Overflow or by Chris Tosswill
Published on 2010-03-09T15:43:51Z Indexed on 2010/03/11 17:29 UTC
Read the original article Hit count: 151

Filed under:
|
|

So I have a rather basic javascript problem which I have been slamming my head into a wall over for awhile:

<div class='alist'>
   <ul> 
       <li class='group_1'> An Item </li>
       <li class='group_1'> An Item </li>
       <li class='group_2'> An Item </li>
   </ul>
</div>

<div class='alist'>
   <ul> 
       <li class='group_1'> An Item </li>
       <li class='group_1'> An Item </li>
       <li class='group_2'> An Item </li>
   </ul>
</div>


<script>
function toggle_item( num ){
    $$( 'li.group_' + num ).invoke('toggle');
}
</script>

Basically, I need to create a sweeper that sets the div to display:none if all the li are display:none.

I think it would start like:

function sweep(){
    $$('div.alist').each( function( s ) {
      ar = s.down().children
    }); 
} 

Any suggestions for good tutorials would be welcome as well

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about prototypejs