Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery: How to determine if a radio button has been selected?

How can I determine if my radio buttons are selected?

For example:

if ( radio_button_selected ) {

// do something

} else {

// do something else

}
like image 391
StaceyH Avatar asked Nov 09 '10 22:11

StaceyH


1 Answers

You can use this selector to determine if any are checked:

jQuery("input[name='my_button_group']:checked")

So for example:

if (jQuery("input[name='my_button_group']:checked")) {
    ...
}
else {
    ...
}
like image 103
Justin Ethier Avatar answered Sep 22 '22 18:09

Justin Ethier