jquery get selected radiobutton in javascript

To get the selected radio button using jQuery in JavaScript, you can use the :checked selector along with the val() method. Here is an example:

index.tsx
// assuming you have a group of radio buttons with the same name "gender"
var selectedValue = $('input[name=gender]:checked').val();
133 chars
3 lines

In this example, we are selecting the radio buttons with the name "gender" that are currently checked. We then use the val() method to get the value of the selected radio button.

You can replace "gender" with the name of your own radio button group. Make sure the name is the same for all the radio buttons in the group.

gistlibby LogSnag