我使用星级http://www.fyneworks.com/jquery/star-rating/
我不明白如何在提交表单后获取用户检查的隐藏收音机的值
这里的代码:
<div class="line mrgT mrgB" id="starVin">
<input name="star1" type="radio" class="star" value="1" />
<input name="star1" type="radio" class="star" value="2" />
<input name="star1" type="radio" class="star" value="3" />
<input name="star1" type="radio" class="star" value="4" />
<input name="star1" type="radio" class="star" value="5" />
</div>
Run Code Online (Sandbox Code Playgroud)
我试试这个
alert( $('#formComent .star1:checked').val() );
Run Code Online (Sandbox Code Playgroud)
不起作用...
您将需要[name="star1"]在选择器中使用,因为它是名称,或者.star因为它是类,而不是star1. 您的 形式上可能有一个 ID formComment,但由于它不包含在您的示例中,因此也可以starVin在选择器中使用:
jQuery.noConflict();
alert( jQuery('#starVin input[name="star1"]:checked').val() );
Run Code Online (Sandbox Code Playgroud)
或者
alert( jQuery('#starVin .star:checked').val() );
Run Code Online (Sandbox Code Playgroud)
如果要测试,checked可以使用以下is()方法:
$('#starVin input[name="star1"]').each(function(){ alert($(this).is(':checked')); });
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3143 次 |
| 最近记录: |