How can I find out which radio button is selected using jQuery without searching for the radio group each time?

Var myRadio = jQuery("inputname=myradiogroup"); var selectedRadio = myRadio. Filter(":checked"); alert( selectedRadio.val() ).

Hmm, that's odd... I saw an answer like that in the linked question but I couldn't get it to work. I'll try again, but it seems like . Find is searching for child elements, ignoring the radio group itself, so I always get an empty result.

– RenderIn Aug 24 '10 at 16:24 find will only look in descendants, so it will return an empty set since the checkbox elements have no descendants and calling val on that empty set will return undefined – Anurag Aug 24 '10 at 16:28 Whoops, should be filter. That is what I get for answering and eating at the same time. Altered the code.

– epascarello Aug 24 '10 at 16:42 Sample code: jsbin. Com/ikuha – epascarello Aug 24 '10 at 16:44.

MyValue=""; $('inputname=myradiogroup'). Change(function() { myValue= this. Value; alert(myValue); }); Now you can check "myValue" anytime you wish.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions