使用JQuery检查第一个单选按钮 [英] Check first radio button with JQuery

查看:107
本文介绍了使用JQuery检查第一个单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to check the first radio button of each group. But there are some radio button that are disabled, so the script should ignore them and go to next non-disabled button.

我写了这样的东西,但是没用:

I wrote something like this but it doesn't work:

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

非常感谢

推荐答案

如果您的按钮按其name属性分组,请尝试:

If your buttons are grouped by their name attribute, try:

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

如果它们是由父容器分组的,则:

If they are grouped by a parent container, then:

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

这篇关于使用JQuery检查第一个单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆