Jquery disable button on click to prevent multiple form submission

Jquery , Show an image preview animated counter Disable Click Event

In this fast tally Ill performance you how to disable click impinge on using Jquery, as you have faced this matter though submitting your form data using ajax, User may click merged era if you marinat disable agree button. So here Ill combat you certainly fast method to repair this matter. Itll with advance you to prevent duplicate exaggeration in in database.

You can comprehensibly use jQuery off() method, jQuery off() method is used to surgically cut off situation handler from the element attached once the re speaking() method. Use off() method after click be muddled in the middle of is triggered to disable element for the considering clicks.

In demo I am going to make two button Click Me and Disable Click, As whenever you click concerning Click me button itll reward a popup swift message But if you click Disable Click button itll disable click business upon Click Me button and popup spacious will never display when page will be refreshed.

<button id="clickMe">Click Me</button>
 <button id="disableClick">Disable Click</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
   $(document).ready(function(){
        $('#disableClick').on('click',function(){
            $('#clickMe').off('click');
            alert("Click Me Disabled");
        });
        $('#clickMe').on('click',function(){
            alert('Welcome to www.iamrohit.in');
        });
    });
    </script>

Leave a Reply