[jQuery] Re: checkbox manipulation and toggle()

2008-05-30 Thread benjam

Although you need to make sure that you set the for attribute o the
label tag to the id attribute of the input tag, NOT the name
attribute.
One way to get around this issue (and the recommended method) is to
set the name and id attribute of the input tag the same.
If you wrap the input tag with the label tag, there is no need to
include the for attribute, bu if the label is not wrapping the input
tag, it needs to be included.

e.g.-

Please check this box 

This is my checkbox 



On May 29, 12:16 pm, jquertil <[EMAIL PROTECTED]> wrote:
> Hello...
>
> short version: how do I exclude an element in my selector expression?
>
> long version:
>
> you know those checkboxes in windows where you can actuyally click the
> label to check the box?
>
> I'm recreating this with a toggle() like this:
>
>  Click
> here
>
> $("#CheckContainer").toggle(
> function(){ $('#Check')[0].checked=true;},
> function(){ $('#Check')[0].checked=false;}
> );
>
> All fine and dandy as you click the DIV to toggle the checkbox. But
> try to click the checkbox itself and the darn thing won't work.
>
> I think the solution is in using the right sleector, like some kind
> of :not or !:input or something ???
> Ii DON"T want to have to add a span element around the label to assign
> the click to, I'd like to just exclude the checkbox.


[jQuery] Re: checkbox manipulation and toggle()

2008-05-29 Thread steve_f

you need a label and set its for attribute to the checkbox


On May 29, 7:21 pm, jquertil <[EMAIL PROTECTED]> wrote:
> OK I tried my own anticipated solution after looking at some comment
> from The Man Himself, but didn't work.
>
> $("#CheckContainer:not(#Check)").toggle(...); --- does not work. stil
> can not click the checkbox :(


[jQuery] Re: checkbox manipulation and toggle()

2008-05-29 Thread Bart Hermans
Actually, this is a standard implementation in html: use the  tag.

On Thu, May 29, 2008 at 8:16 PM, jquertil <[EMAIL PROTECTED]> wrote:

>
> Hello...
>
> short version: how do I exclude an element in my selector expression?
>
>
> long version:
>
> you know those checkboxes in windows where you can actuyally click the
> label to check the box?
>
> I'm recreating this with a toggle() like this:
>
>  Click
> here
>
>
>$("#CheckContainer").toggle(
>function(){ $('#Check')[0].checked=true;},
>function(){ $('#Check')[0].checked=false;}
>);
>
> All fine and dandy as you click the DIV to toggle the checkbox. But
> try to click the checkbox itself and the darn thing won't work.
>
> I think the solution is in using the right sleector, like some kind
> of :not or !:input or something ???
> Ii DON"T want to have to add a span element around the label to assign
> the click to, I'd like to just exclude the checkbox.
>


[jQuery] Re: checkbox manipulation and toggle()

2008-05-29 Thread jquertil

OK I tried my own anticipated solution after looking at some comment
from The Man Himself, but didn't work.

$("#CheckContainer:not(#Check)").toggle(...); --- does not work. stil
can not click the checkbox :(