If your HTML is like this:

<label>Label text here<input type="checkbox" /></label>

then you can give the label an ID and hide that.

<label id="myLabel1">Label text here<input type="checkbox" /></label>

$('#myLabel1').hide ();

If you're using the FOR attribute to hide then there are a few
approaches.  The easiest would be to give the checkbox and associated
label the same class.

<label for="foo" class="myLabel1">Label text here</label><input
type="checkbox" id="foo" class="myLabel1" />

$('.myLabel1').hide ();

If you can't use classes for whatever reason then you could start
trying some trickier stuff.

<label for="foo">Label text here</label><input type="checkbox"
id="foo" />

$('#foo, label[for="foo"]').hide ();

Be aware there is a slight speed penalty for using classes instead of
IDs, and there's a quite substantial speed penalty for using []
attribute matching instead of IDs or classes.  For that reason I'd
recommend using IDs or classes and try to avoid the fancier
selectors.  Your web app will be snappier for it.

Don't know how helpful this is but I hope you can find some use for
it.

On Nov 14, 6:56 pm, "Priest, James (NIH/NIEHS) [C]"
<[EMAIL PROTECTED]> wrote:
> Argh - I'm close - but so far I can't seem to hide BOTH the checkbox and
> label:
>
> $('h3').click(function() {
> $(this).next('.details').find("input:checkbox").not(":checked").hide();
>
> });
>
> OR
>
> $('h3').click(function() {
> $('input:checkbox').each(function() {
>         if (!this.checked)
>         {
>               $(this).next().hide();
>         }
>         });
>  });
>
> Both hide the checkbox only. The label remains!!
>
> I've tried a few things with parent().next() but either I can remove the
> checkbox OR the label but never both??
>
> I'm sure I'm missing something simple here????
>
> Thanks,
> Jim

Reply via email to