jQuery: Disable a button

At times, you may want the submit button of a form or one of its text inputs to be disabled until the user has performed a certain action (e.g., checking the “I’ve read the terms” checkbox).

Add the disabled attribute to your input so you can enable it when you want.  You can try clicking on the submit button to see its effect.

<!DOCTYPE html>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <title>Check image load</title>      
            $(function () {
                $('input[type="submit"]').prop('disabled', true);
            <input type="text" name="first" value="Taylor Swift">
            <input type="submit" value="Submit">


All you need to do is run the prop method again on the input, but set the value of disabled to false to enable the button.

$('input[type="submit"]').prop('disabled', false);