jQuery disable/enable submit button

后端 未结 21 3095
难免孤独
难免孤独 2020-11-22 07:30

I have this HTML:



How can I do something li

21条回答
  •  终归单人心
    2020-11-22 07:51

    The answers above don't address also checking for menu based cut/paste events. Below's the code that I use to do both. Note the action actually happens with a timeout because the cut and past events actually fire before the change happened, so timeout gives a little time for that to happen.

    $( ".your-input-item" ).bind('keyup cut paste',function() {
        var ctl = $(this);
        setTimeout(function() {
            $('.your-submit-button').prop( 'disabled', $(ctl).val() == '');
        }, 100);
    });
    

提交回复
热议问题