Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable all form elements inside div

People also ask

How do I make all elements in a div disabled?

find(':input'). prop('disabled', false); $('#my_div a'). unbind("click");

How disable all controls inside a div using jQuery?

Answer: To disable all input elements within div use the following code: $('#message :input'). attr('disabled', true);

How do you make a whole form disabled?

To disable all form controls within a fieldset , use the disabled attribute like this <fieldset disabled> . You probably already have some CSS styling that should apply to disabled form controls. This usually also works within a field set without changing anything.

How do you make a whole form Disabled in HTML?

Wrap the input fields and other stuff into a <fieldset> and give it the disabled="disabled" attribute.


Try using the :input selector, along with a parent selector:

$("#parent-selector :input").attr("disabled", true);

$('#mydiv').find('input, textarea, button, select').attr('disabled','disabled');

For jquery 1.6+, use .prop() instead of .attr(),

$("#parent-selector :input").prop("disabled", true);

or

$("#parent-selector :input").attr("disabled", "disabled");

    $(document).ready(function () {
        $('#chkDisableEnableElements').change(function () {
            if ($('#chkDisableEnableElements').is(':checked')) {
                enableElements($('#divDifferentElements').children());
            }
            else {
                disableElements($('#divDifferentElements').children());
            }
        });
    });

    function disableElements(el) {
        for (var i = 0; i < el.length; i++) {
            el[i].disabled = true;

            disableElements(el[i].children);
        }
    }

    function enableElements(el) {
        for (var i = 0; i < el.length; i++) {
            el[i].disabled = false;

            enableElements(el[i].children);
        }
    }