Loop through input/select to check for class

Loop through input/select to check for class

Hi all.

In the 'else' section of my code below I am having an issue. What I am trying to do, is to find if each of the input, or selects in the div has a class of 'hidden'. If it does add the class 'required' and remove the class 'hidden'. The problem is, because one has hidden, it adds required to all. How can I loop through each input/select to check each individually?

  1. $('#order_shipping_same_as_billing').change(function() {
            if ($(this).is(':checked')) {
                $('#shipping_details').css({ opacity : 0.4 });
                $("#shipping_details input, #shipping_details select").attr("disabled", "disabled");
                if ($('#shipping_details input, #shipping_details select').is('.required')) {
                    $('#shipping_details input, #shipping_details select').addClass('hidden').removeClass('required error_required');
                }
            } else {
                $('#shipping_details').css({ opacity : 1 });
                $("#shipping_details input, #shipping_details select").removeAttr("disabled");
                if ($('#shipping_details input, #shipping_details select').is('.hidden')) {
                    $('#shipping_details input, #shipping_details select').addClass('required').removeClass('hidden');
                }
            }
        });














Thank you :)