View Tutorial Metadata Edit Content Revision History Add to Watchlist Add New Tutorial How to get the value of the selected radio button in jQuery

How to get the value of the selected radio button with jQuery

If you want to get the value of the selected radio button from a structure like this :

<input type="radio" name="radio_btn" value="value1" /> Option 1
<br />
<input type="radio" name="radio_btn" value="value2" /> Option 2

You can use the following jQuery code :

// Get the value
var selected = $('[name=radio_btn]:checked').val();
// Display it
alert(selected);

That was all :) Pretty simple, eh?

Only plain text supported.

Optional

Required - will be kept private

Optional

 
 

Rating: (1+, 0-) In: jQuery