简体   繁体   中英

how to enable and disable radio buttons to checkboxes with JQ

I need to disable and enable 3 radio button with a checkbox starting from this switch

jQuery("input:checked").each(function () {
        var valore = jQuery(this).val();
        if(str != ""){
            str += " + ";
        }
        switch(valore)
                {
                    case "1": 
                       str += "casa";
                       if(num == "") num = "cooc €";                                            
                    break;
                    case "2": 
                       str += "Struttura";
                       if(num == "") num = "cccd";
                    break;
                    case "3": 
                       str += "inserzione";
                       if(num == "") num = "ddds;";
                    break;
                    default:;
                }

Html

<input id="radio-01" value="3" name="radio" type="radio" class="rambo" />
<input id="radio-01" value="3" name="radio" type="radio" class="rambo" />
<input id="radio-01" value="3" name="radio" type="radio" class="rambo" />
<input id="radio-01" value="3" name="checkbox" type="checkbox" class="rambo" />

Help me Thanks for advice

Love the class name.

You should use $('input [type="radio"]).attr('checked', true) inside your switch if you want to check all 3 radios.

$('input[type="radio"]').attr('disabled', true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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