views:

116

answers:

1

I am able to use the following to get the value of the selected radio button (of the radio button list rblReason)

var reasonId = $('#rblReason').find('input[checked]').val();

How can I get the innerText of the radio button selected? ty

+1  A: 

A radio button has no innerText, it is an empty element. What is your markup?

If you have a parent which contains the text you want:

<div> <input type="radio" name="thing" value="foo" /> Hello </div>

Then you could use:

var text= $('#rblReason input:checked').parent().text();

If you have a label element associated with the radio:

<input type="radio" name="thing" value="foo" id="thing-foo" />
<label for="thing-foo"> Hello </label>

then you could do:

var id= $('#rblReason input:checked').attr('id');
var text= $('label[for='+id+']').text();

Note, use :checked to see which checkbox/radio is currently selected. [checked] means testing that the element has a checked attribute, which will always return the initially-checked radio regardless of what the user has selected. [Except in IE, due to a bug.]

bobince
Thank you this was the solution I was looking for.
David