Reputation: 6264
i have defined radio buttons as bellow
<tr>
<th height="35" scope="row">
<div align="left">Response for Instruction</div>
</th>
<th scope="row"><input name="a" type="radio" value="Excellent" /></th>
<th scope="row"><input name="a" type="radio" value="Good" /></th>
<th scope="row"><input name="a" type="radio" value="Poor" /></th>
<th scope="row"><input name="a" type="radio" value="Needs Improvement " /></th>
</tr>
$(document).ready(function() {
var a = $('#a').attr('value');
alert(a);
}
but its showing undefined.
Thanks
Upvotes: 0
Views: 1546
Reputation: 1289
Try This
$("input:radio[name=a]").click(function() {
var value = $(this).val();
console.log(value);
});
Upvotes: 2
Reputation: 34107
Working demo http://jsfiddle.net/qh6Et/3/
code
$("input[type='radio']").click(function(){
var a = $(this).attr('value');
alert(a);
});
Upvotes: 1