简体   繁体   English

检查下一个未禁用单选按钮

[英]check next not disabled radio button

I have a bunch of radio buttons, and depending on the choices of other radio buttons, some of radio's are disabled. 我有一堆单选按钮,根据其他单选按钮的选择,某些单选按钮被禁用。 The problem is that they the disabled ones remain checked. 问题是,他们仍然检查残疾人。 It's hard to explain this and it's not something I can show in code, because it's just a bunch of garbage and experiments. 很难解释这一点,这不是我可以在代码中显示的内容,因为这只是一堆垃圾和实验。

So anyway, my question is, how do you find the first not disabled radio button in a radio button group (same name)? 所以无论如何,我的问题是,如何找到单选按钮组(名称相同)中的第一个未禁用的单选按钮?

Thanks for your help. 谢谢你的帮助。

$(':radio:not(:disabled):first')

没有先,它会找到所有未禁用的无线电。

You can find all radiobuttons with :radio 您可以找到所有带有:radio按钮

You can reduce that result with :not 您可以使用:not减少结果

You can target all disabled elements with :disabled 您可以使用:disabled定位所有禁用的元素

You can return the first element from the given set with :first 您可以使用:first返回给定集合中的第一个元素

$('input:radio:not(:disabled):first')

If you want to find out which radiobutton is checked, disregarding any disabled ones, you may want to do something like 如果要找出选中了哪个单选按钮,而忽略所有禁用按钮,则可能需要执行以下操作

$('input:radio:checked:not(:disabled)')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM