duckmike
duckmike

Reputation: 1036

JQuery - Getting selected radio button value

My JQuery function looks like, where a$RadioBtn is the one only radio button list on my form:

IR.Web.cRptCtl.prototype.getSelectedRadioValue = function(a$RadioBtn){
  //Here I want to return a$RadioBtn's selected value
}

How do I determine the selected value?

Upvotes: 0

Views: 446

Answers (3)

Jonathan Moffatt
Jonathan Moffatt

Reputation: 13457

$("input[name='name_of_radio']:checked").val();

Upvotes: 0

Rob W
Rob W

Reputation: 349252

If a$RadioBtn is a JQuery object of the radio elements, use:

a$RadioBtn.filter(":checked");

This will return a JQuery object, representing the selected radio input field. If you want to perform DOM operations on it, use the .get(0) method to get the DOM element.

Example:

IR.Web.cRptCtl.prototype.getSelectedRadioValue = function(a$RadioBtn){
    var selected = a$RadioBtn.filter(":checked");
    alert(selected.val());
}

Upvotes: 1

Senad Meškin
Senad Meškin

Reputation: 13756

$('input[name="your_radio_name"]).is('checked').val();

this will return value of your selected radio button

Upvotes: 1

Related Questions