disable all form elements inside div

后端 未结 12 1797
栀梦
栀梦 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条回答
  •  旧时难觅i
    2020-12-04 08:52

    If your form inside div simply contains form inputting elements, then this simple query will disable every element inside form tag:

    ...

    However, it will also disable other than inputting elements in form, as it's effects will only be seen on input type elements, therefore suitable majorly for every type of forms!

    $('#myForm *').attr('disabled','disabled');
    

提交回复
热议问题