Disable/enable an input with jQuery?

后端 未结 18 2676
礼貌的吻别
礼貌的吻别 2020-11-21 07:47
$input.disabled = true;

or

$input.disabled = \"disabled\";

Which is the standard way? And, conversely, how do yo

18条回答
  •  礼貌的吻别
    2020-11-21 07:53

    2018, without JQuery (ES6)

    Disable all input:

    [...document.querySelectorAll('input')].map(e => e.disabled = true);
    

    Disable input with id="my-input"

    document.getElementById('my-input').disabled = true;
    

    The question is with JQuery, it's just FYI.

提交回复
热议问题