lundi 7 mai 2018

Check or uncheck a checkbox if another one is checked with jQuery

I have a basic if/else statement that checks if two inputs are checked, if they are, a third checkbox state of "disabled" turns to false and it can be checked. I would like that once checked, if the other checkboxes are unchecked, this one would go unchecked again, but it just gets disabled while mantaining the check.

My code:

$("#cvLinkedInAssessmentCheck :input, #rolePlayingTalentCheck :input").change(function(){
        if( $(this).is(':checked') ){
            $("#minutosTalentoCheck :input").attr("disabled", false);
            $("#minutosTalentoCheck").css("opacity", "1");
        } else {
            $("#minutosTalentoCheck").prop('checked', false);
            $("#minutosTalentoCheck :input").attr("disabled", true);
            $("#minutosTalentoCheck").css("opacity", "0.3");

        }
    })

Basically, this line in the else statement is not working, I have also tried with "attr" instead with no luck:

$("#minutosTalentoCheck").prop('checked', false);




Aucun commentaire:

Enregistrer un commentaire