我想知道是否可以移至下一个单选按钮
这是我从 Selecting next radio button from selected one 复制的简单 fiddle
https://jsfiddle.net/5pn69jed/
$('.next').click(function() {
$("input[name=choice]:checked").next().next().click();
});
最佳答案
您的代码在 Two
处停止,因为 two
已禁用。 Two.next().next() = 3,但 Three.click() 不执行任何操作,因为它已被禁用。
删除三个中的禁用,您会发现它工作正常。
您可以使用.nextAll("input:enabled").first()
查找下一个启用的输入
$('.next').click(function() {
$("input[name=choice]:checked").nextAll("input:enabled").first().click();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="radio" id="choise_1" name="choice" checked="checked" />
<label for="choise_1">One</label>
<input type="radio" id="choise_2" name="choice" />
<label for="choise_2">Two</label>
<input type="radio" id="choise_3" name="choice" disabled="disabled" />
<label for="choise_3">(Three)</label>
<input type="radio" id="choise_4" name="choice" />
<label for="choise_3">Four</label>
<button class="next">SELECT NEXT</button>
关于javascript - 跳转到下一个非禁用单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55019599/