How to Disable Click Event using jQuery

Perhaps you were faced with a common problem when you’re using jQuery Ajax to submit a form, the form data is submitted multiple times if the submit button is clicked multiple times. To solve this issue you only need to write one line code in jQuery.
jQuery off() method is used to remove event handler from the element attached with the on() method. Use off() method after click event is triggered to disable element for the further click.


The following code snippet is a real-time example for disabling click event using jQuery.

<!DOCTYPE html>
<html lang="en-US">
    <script src=""></script>
            alert('Welcome to CodexWorld!');
    <button id="clickElement">Click Here</button>
    <button id="disable">Disable Click</button>


Leave a reply

CodexWorld Newsletter

Subscribe CodexWorld updates via email and get every new post delivered to your inbox.