Klaus Hartl wrote:
>
>
> Andrew Buzzell schrieb:
>> With a checkbox inside of a label, I was trying to toggle a class on
>> the label based on whether the input was checked or not. I tried
>> every permutation of:
>>
>> $(".checkbox").change(function(){
>> $(this).parent().toggleClass('selected');
>> });
>>
>> <label for="test"><input id="test" type="checkbox" class="checkbox
>> />Test</label>
>>
>> Tried both the dev and the current jquery. Any idea what I'm doing
>> wrong?
>
> I think the change event does not apply to checkboxes. Try click,
> which is the same as change apparently:
>
> $(".checkbox").change(function(){
> $(this).parent().toggleClass('selected');
> });
>
Actually, that still doesn't work. It adds the class, but won't remove it.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/