tags:

views:

48

answers:

2

Hi

I want to use jQuery to get the checked radio button out of a radio button set.

The form object here is not a jQuery object but rather "normal" javascript object.

I want the following:

//"where" should fliter the jQuery Array
var myVal = $(form.RadioSet).where(':checked').val();

I know I can get my results with this:

var myVal = $(form).find('input[name=RadioSet]:checked').val();

But that's a little bit more typing with the "input" and the "name" syntax.

Any ideas?

Thanks,

+1  A: 

http://api.jquery.com/filter/

var myVal = $(form.RadioSet).filter(':checked').val();
Ian Wetherbee
+2  A: 

I think .filter() is what you're looking for...

as in:

var myVal = $(form.RadioSet).filter(':checked').val();
Brian Driscoll
How could I have missed that? Many thanks!
Chi Chan
np... please be sure to mark this as your accepted answer.
Brian Driscoll
Yup, still waiting for the "You can accept an answer in 1 minute" box to go. :)
Chi Chan