enabled disabled button jquery
To enable and disable a button using jQuery, you can use the .prop() method. Here's an example: Click me to enable/disable $(document).ready(function () { $('#btn-example').click(function () { $(this).prop('disabled', !$(this).prop('disabled')); }); }); The above code uses the jQuery .prop() method to enable and disable the button. When the button is clicked, the .prop() method will toggle the disabled value between true and false. You can also enable and disable the button directly on page load by setting the disabled attribute to true or false. Here's an example: Click me to enable/disable $(document).ready(function () { $('#btn-example').click(function () { $(this).prop('disabled', !$(this).prop('disabled')); }); }); In this example, setting the disabled attribute to true will disable the button on page load. You can also use the .attr() method to set the disabled attribute, like this: Click me to enable/disable $(document).ready(function () { $('#btn-example').attr('disabled', 'true'); $('#btn-example').click(function () { $(this).prop('disabled', !$(this).prop('disabled')); }); }); There are other ways to enable and disable a button with jQuery, such as using the .toggleClass() and .removeClass() methods. However, the .prop() method is the most efficient way to enable and disable a button.