我有两个单选按钮:
div.span3
input.action.input(type='radio', name='action', value='push')
Push
input.action.input(type='radio', name='action', value='pull')
Pull
我需要找出被选中/选中的单选按钮的值。我尝试了不同的方法,但没有一个工作:
$(@el).find("input[name='action']:radio:checked").text()
$(@el).find("input:radio[name='action']:checked").val()
$(@el).find(".action :checked").val()
我使用NodeJS + coffeescript + Jade + JQuery,这里是单选按钮的HTML:
<div class="span3">
<input type="radio" name="delivery-action" value="push" class="delivery-action input"> Push <input type="radio" name="delivery-action" value="pull" class="delivery-action input"> Pull
</div>
答案 0 :(得分:0)
var selectedVal = "";
var selected = $("#radioDiv input[type='radio']:checked");
if (selected.length > 0) {
selectedVal = selected.val();
}