disable all form elements inside div

后端 未结 12 1801
栀梦
栀梦 2020-12-04 08:39

is there a way to disable all fields (textarea/textfield/option/input/checkbox/submit etc) in a form by telling only the parent div name in jquery/javascript?

12条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 08:56

    I'm using the function below at various points. Works in a div or button elements in a table as long as the right selector is used. Just ":button" would not re-enable for me.

    function ToggleMenuButtons(bActivate) {
        if (bActivate == true) {
            $("#SelectorId :input[type='button']").prop("disabled", true);
        } else {
            $("#SelectorId :input[type='button']").removeProp("disabled");
        }
    }
    

提交回复
热议问题