Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to enable/disable a button with jQuery?

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 460
    Comment on it

    Sometimes we need to enable/disable a button based on some condition. We can do this easily by using "disable" attribute of a button.

    Example:

    <button type="button" id="voteButton">vote</button>
    

    To disable a button write the below line:

    $("#voteButton").attr('disabled', 'disabled');
    

    or

    $("#voteButton").attr("disabled",false);
    

    To enable again after disabling the button:

    $('#voteButton').removeAttr('disabled');
    

    or

    $('#voteButton').attr("disabled",true);
    

    Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: