How can I know which radio button is selected via jQuery?

I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery?

I can get all of them like this:

$(form :radio) 

How do I know which one is selected?

Text Copied From
on : Fri, Feb 27, 2009 Views : 1796161

Accepted Answer

To get the value of the selected radioName item of a form with id myForm:

$('input[name=radioName]:checked', '#myForm').val() 

Here's an example:

$('#myForm input').on('change', 

 alert($('input[name=radioName]:checked', '#myForm').val());
<script src=https:
//></script> <form id=myForm> <input type=radio name=radioName value=1 /> 1 <br /> <input type=radio name=radioName value=2 /> 2 <br /> <input type=radio name=radioName value=3 /> 3 <br /> </form>

Text Copied From
on : Fri, Feb 27, 2009

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp