Search code examples
javascriptjquerydomradio-button

Show an element if all radio boxes have a selection in jQuery


I am trying to make a form show/hide a submit button dependant on if all the radio elements have a selection - this is what i've got so far.. Any ideas what i'm doing wrong?

$(document).ready(function() {
    $('#submit-btn').hide();

    if ($(':radio:checked').length > 0) {//try reach selected radio here
        $('#submit-btn').show();
    }
});

Solution

  •  $('.toCheck').length == $('.toCheck:checked').length;
    

    If that evaluates to true, then all input for that selector are checked! :)