Disable/enable an input with jQuery?

后端 未结 18 2711
礼貌的吻别
礼貌的吻别 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 08:09

    Disable:

    $('input').attr('readonly', true); // Disable it.
    $('input').addClass('text-muted'); // Gray it out with bootstrap.
    

    Enable:

    $('input').attr('readonly', false); // Enable it.
    $('input').removeClass('text-muted'); // Back to normal color with bootstrap.
    

提交回复
热议问题