How to disable all <input > inside a form with jQuery?

后端 未结 8 1247
感动是毒
感动是毒 2021-01-29 22:35
....
相关标签:
8条回答
  • 2021-01-29 23:18

    In older versions you could use attr. As of jQuery 1.6 you should use prop instead:

    $("#target :input").prop("disabled", true);
    

    To disable all form elements inside 'target'. See :input:

    Matches all input, textarea, select and button elements.

    If you only want the <input> elements:

    $("#target input").prop("disabled", true);
    
    0 讨论(0)
  • 2021-01-29 23:26

    To disable all form, as easy as write:

    jQuery 1.6+

    $("#form :input").prop("disabled", true);
    

    jQuery 1.5 and below

    $("#form :input").attr('disabled','disabled');
    
    0 讨论(0)
提交回复
热议问题