gpt4 book ai didi

jquery - 使用 JQuery 检查第一个单选按钮

转载 作者:行者123 更新时间:2023-12-03 21:32:08 25 4
gpt4 key购买 nike

我想检查每组的第一个单选按钮。但是有一些单选按钮被禁用,因此脚本应该忽略它们并转到下一个非禁用按钮。

我写了这样的东西,但它不起作用:

$(document).ready(function(){if ($("input['radio']).is(':disabled'))    {          $(this).attr('checked', false );    }else    {        $(this).attr('checked', true );    }});

非常感谢

最佳答案

如果您的按钮按名称属性分组,请尝试:

$("input:radio[name=groupName][disabled=false]:first").attr('checked', true);

如果它们按父容器分组,则:

$("#parentId input:radio[disabled=false]:first").attr('checked', true);

关于jquery - 使用 JQuery 检查第一个单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3977699/

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