To get the value of selected radio button, a user-defined function can be created that gets all the radio buttons with the name attribute and finds the radio button selected using the checked property. The checked property returns True if the radio button is selected and False otherwise. If there are multiple Radio buttons in a webpage, first, all the input tags are fetched and then the values of all the tags that have type as ‘radio’ and are selected are displayed.
Example 1: The following program displays the value of selected radio button when user clicks on Submit button.
Example 2: The following program displays values of all the selected radio buttons when submit is clicked.
- How to know which radio button is selected using jQuery?
- How to check a radio button with jQuery?
- button tag vs input type="button" attribute
- jQuery | :selected Selector
- AngularJS | ng-selected Directive
- HTML | selected Attribute
- jQuery | :radio Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.