Disable or enable Submit button on Checkbox checked event

前端 未结 4 2134
陌清茗
陌清茗 2020-12-30 13:57

I want something like this but with a slight change. I want a Button to be enabled or disabled on Checkbox checked event, i.e. when checkbox is checked then and then only b

4条回答
  •  生来不讨喜
    2020-12-30 14:26

    $(function() {
        $('#id_of_your_checkbox').click(function() {
            if ($(this).is(':checked')) {
                $('#id_of_your_button').attr('disabled', 'disabled');
            } else {
                $('#id_of_your_button').removeAttr('disabled');
            }
        });
    });
    

    And here's a live demo.

提交回复
热议问题