gpt4 book ai didi

jquery 星级评定获取值单选隐藏

转载 作者:行者123 更新时间:2023-12-01 03:18:13 26 4
gpt4 key购买 nike

我使用星级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>

我试试这个

alert( $('#formComent .star1:checked').val() );

不起作用...

最佳答案

您需要在选择器中使用 [name="star1"] 因为它是名称,或者 .star 因为它是类,而不是 star1。您的表单 formComment 上可能有一个 ID,但由于它未包含在您的示例中,因此也在选择器中使用 starVin:

jQuery.noConflict();
alert( jQuery('#starVin input[name="star1"]:checked').val() );

alert( jQuery('#starVin .star:checked').val() );

http://jsfiddle.net/tayNH/

如果您想测试checked,您可以使用is()方法:

$('#starVin input[name="star1"]').each(function(){ alert($(this).is(':checked')); });

关于jquery 星级评定获取值单选隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13089246/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com