jQuery Disable Button after Click

In this tutorial we will learn how to Disable Button after Click with jQuery. We can use jQuery prop() method, click() method and disabled property to disable the button after click.

prop() method

jQuery prop() method sets or returns the properties and values of the selected HTML tag or element.

In this example prop() method is used to set disabled property value to true.

click() method

jQuery click() method binds the click event with execution of code or it triggers the click event for the HTML element.

In this example click() method is used to run a code on click of a button tag.

disabled property

disabled property is a Boolean property which disables or enables the HTML element.

If disabled property is set to true then it will disable the HTML tag.

HTML Code

HTML Code is given below, in this code we have a button tag with a defined id.

<!DOCTYPE html>
<html>
<head>
<title>jQuery Disable Button after Click</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>    
</head>             
<body>

<button id="btn">Disable Me!</button>    
    
<script src="script.js"></script>    
</body>
</html>

JQuery Code

JQuery Code is given below, jQuery click() method is used to tie the execution of code with click event of button tag.

prop() method is used to set the value of disabled property to true which will disable the button tag.

<script>
$(document).ready(function(){
  $('#btn').click(function(){
    $('#btn').prop("disabled","true");        
  });
});
</script>

Demo

Video Tutorial

Watch video tutorial on How To Disable Button after Click with jQuery.

Check radio button Dynamically with jQuery Change Background Color on hover with jQuery Hide and Show div using jQuery Get value of input element with jQuery Remove last child of parent element with jQuery Add li tag to the end of list jQuery Delete first row of Table with jQuery Delete last row of Table with jQuery Add first list item using jQuery jQuery Get id of Button jQuery toggle show hide on click Disable Button after Click with jQuery Get Button Text with jQuery jQuery Dynamic li Click Event How To Remove all Spaces in String with jQuery Get Selected file name in jQuery Remove Last Option of Select tag with jQuery Remove First Option from Select tag in jQuery jQuery Capitalize First Letter of String jQuery Check input value length jQuery Count all elements with same Class jQuery Get Checked Radio Button Value By Class jQuery Highlight Text in Div Get Checked Radio Button Value By Name in jQuery Get Checked Radio Button Value By id jQuery