views:

43

answers:

1

What is the right jQuery selector to use for all fieldset elements which have only checkboxes in them? I tried $("fieldset:has(input:checkbox") but that didn't work.

Help? Thanks

+2  A: 

I believe the following will work:

$("fieldset:has(input[type='checkbox'])")
Jonathan Sampson
Yes, this works! Thanks. Do you know why my attempt was not working? input:checkbox is a valid selector as well as per http://docs.jquery.com/Selectors/checkbox
VANJ
@VANJ: you were missing a closing `)` after `:checkbox`. Otherwise this answer is functionally equivalent to `input:checkbox`.
Crescent Fresh
Duh, you are right. If I want to extend this approach to checkboxes or radiobuttons, $("fieldset:has(input:radio),fieldset:has(input:checkbox)") works fine but is there a more concise/efficient way to write this? Thanks
VANJ