0

ラジオボタンを次のように定義しました

<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);
}

しかし、その表示は未定義です。

ありがとう

4

5 に答える 5

5
$("input:radio[name=a]:checked").val()
于 2012-05-24T06:13:18.467 に答える
2

これを試して

 $("input:radio[name=a]").click(function() {
    var value = $(this).val();
    console.log(value);
  });
于 2012-05-24T06:23:05.810 に答える
1

実際のデモ http://jsfiddle.net/qh6Et/3/

コード

$("input[type='radio']").click(function(){
    var a     = $(this).attr('value');
    alert(a);
});
​
于 2012-05-24T06:13:38.123 に答える
0

そのはず

var a = $('input[name="a"]').attr('value');
于 2012-05-24T06:13:25.330 に答える
0

おそらくこれが役立つでしょう...

$("input[@name=a]:checked").val();
于 2012-05-24T06:14:52.337 に答える