Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

How to enable/disable a button using jQuery ?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article, we will demonstrate how to enable and disable buttons using jQuery. This article requires some familiarity with HTML, CSS, JavaScript, and jQuery. The jQuery prop() function can be used to disable a button.  

The property values can be explicitly retrieved using the prop() method. The prop() method only returns the property value for the first matching element in the set. For a property whose value hasn’t been set, or for a matched set that does not contain elements, it returns Undefined.


The selected element’s boolean attribute can be set to true or false using this method. 

$().prop(property, value) 


The function returns a boolean value. Whenever the selected element contains a boolean attribute (disabled, checked), it returns true otherwise.


What is a disabled attribute?

This is a boolean attribute that indicates the element should not be displayed. It is unusable to use an element that is disabled. You can set the disabled attribute to prevent the element from being used until another condition is met (such as checking a box).

Example: When you click the button below, the button above is disabled, and when you double click the button below, the button above is enabled. The prop is applied in this example to demonstrate how it is used correctly and how it can be applied.


<!DOCTYPE html>
    <script src=
<body style="text-align: center; 
    border:2px solid green;
    <h1 style="color:green;">
    <button id="update">
        update me
    <div style="margin-top:50px;">
        <button id="change">
            click me
        $('#change').on('click', function () {
            $('#update').prop('disabled', true);
        $('#change').on('dblclick', function () {
            $('#update').prop('disabled', false);



My Personal Notes arrow_drop_up
Last Updated : 20 Sep, 2021
Like Article
Save Article
Similar Reads
Related Tutorials