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

后端 未结 8 1273
感动是毒
感动是毒 2021-01-29 22:35
....
8条回答
  •  庸人自扰
    2021-01-29 23:05

    Above example is technically incorrect. Per latest jQuery, use the prop() method should be used for things like disabled. See their API page.

    To disable all form elements inside 'target', use the :input selector which matches all input, textarea, select and button elements.

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

    If you only want the elements, use this.

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

提交回复
热议问题