Disable/enable an input with jQuery?

后端 未结 18 3027
礼貌的吻别
礼貌的吻别 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:10

    Just for the sake of new conventions && making it adaptable going forward (unless things change drastically with ECMA6(????):

    $(document).on('event_name', '#your_id', function() {
        $(this).removeAttr('disabled');
    });
    

    and

    $(document).off('event_name', '#your_id', function() {
        $(this).attr('disabled','disabled');   
    });
    

提交回复
热议问题