0
有了这个代码,在我的网页apears几次:访问单选按钮的HTML标签中滑动的价值
<div>
<input type="hidden" name="product" id="productF3" value="7">
<div>
<input type="radio" name="size" id="size_s" value="3"> small size
</div>
<div>
<input type="radio" name="size" id="size_n" value="4"> regular size
</div>
</div>
我有一个问题让所选择的值,从productF3元素开始。 现在,我使用这个代码来解决我的问题:
if($("#productF3").next().children("input[@name=size]:checked").val() != undefined) do something
else if($("#productF3").next().next().children("input[@name=size]:checked").val() != undefined) do something
else alert("Select a size");
但我希望有一个更强大的解决方案,有什么建议?
谢谢!
我发布的html代码在我的页面上出现了好几次,所以我需要确保我获得了“productF3”旁边选中的单选按钮的值。 – VladN
您需要单选按钮而不是复选框,并根据http://api.jquery.com/checkbox-selector/“为了在现代浏览器中获得更好的性能,请改用[type =”checkbox“]。” :收音机有相同的评论。 – Chris
@Hubrus立即检查。 @Chris你说得对。我被那些':checked'选择器弄糊涂:)。 – Beniamin