I know I can use something described here: How can I know which radio button is selected via jQuery?
i.e. jQuery("input[name=myradiogroup]:checked").val()
to get the selected radio button value. But I'd like to cache the radio group and determine which value is selected at a later point in time.
I want to do something like:
var myRadio = jQuery("input[name=myradiogroup]");
//some code
var value = myRadio.getCheckedButton().val();
Any way to do this or do I have to explicitly run the selector with :checked
in it every time I want to find out the selected value?
var myRadio = jQuery("input[name=myradiogroup]");
var selectedRadio = myRadio.filter(":checked");
alert( selectedRadio.val() );
Could do
myRadio.filter(':checked').val()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With