Not necessarily elegant, but it works:
[using your previous code starting with $(this).next() and going from
there.]
$('h3').click(function() {
$
(this).next().children('div').children(':checkbox').not(':checked').parent('div').toggle("fast");
});
This assumes you have the following structure:
<h3>
Heading 1
</h3>
<div id="set1">
<div id="dcb1_1">
<input type="checkbox" name="cb1_1" id="cb1_1"> cbcb1<br />
</div>
<div id="dcb1_2">
<input type="checkbox" name="cb1_2" id="cb1_2"> cbcb2<br />
</div>
</div>
<h3>
Heading 2
</h3>
<div id="set2">
<div id="dcb2_1">
<input type="checkbox" name="cb2_1" id="cb2_1"> cbcb1<br />
</div>
<div id="dcb2_2">
<input type="checkbox" name="cb2_2" id="cb2_2"> cbcb2<br />
</div>
<div id="dcb2_3">
<input type="checkbox" name="cb2_3" id="cb2_3"> cbcb3<br />
</div>
</div>
the ids are entirely not necessary, just a habit.
-Trevor
On Nov 14, 12:38 pm, "Priest, James (NIH/NIEHS) [C]"
<[EMAIL PROTECTED]> wrote:
> 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