Well I've got this:

        $('h3').click(function() {
                        //$(this).next().toggle("fast");
                $(this).toggleClass('down').toggleClass('right');
 
$("input:checkbox").not(":checked").parent().next().hide();
        });

And that hides the checkbox - but I need to hide the associated label as
well.  The parent().next() doesn't work above - I get one extra
(unchecked) item in each group... :(

Jim 

> -----Original Message-----
> From: tlphipps [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 14, 2007 12:05 PM
> To: jQuery (English)
> Subject: [jQuery] Re: how to loop over checkboxes and hide 
> the UNchecked ones?
> 
> 
> You might try this instead of using .each()
> UNTESTED:
> $("input:checkbox").not(":checked").hide();
> 
> On Nov 14, 10:16 am, "Priest, James (NIH/NIEHS) [C]"
> <[EMAIL PROTECTED]> wrote:
> > I've got a series of topics - each with a list of checkboxes.
> >
> > Topic
> > 0 item 1
> > 0 item 2
> > 0 item 3
> >
> > When the user clicks the topic - I have the checklist 
> show/hide using
> > toggle(). What I'd like is when the list closes - the 
> 'checked' items
> > remain visible.
> >
> > Topic
> > X item 2
> > X item 3
> >
> > I'm struggling with how to loop through the list of checkboxes??  My
> > attempt to use .each() isn't working??
> >
> >         $('h3').click(function() {
> >                 // $(this).next().toggle("fast");
> >                 // $(this).toggleClass('down').toggleClass('right');
> >
> >                 $('input:checkbox').each( function() {
> >                         var checked_status = this.checked;
> >                         if (!checked_status)
> >                         {
> >                                 $(this).hide();
> >                         }
> >                 });
> >         });
> >
> > Thanks,
> > Jim
> 
> 

Reply via email to