Prevent second button click using jQuery

Benny

I have a button on my page. I don't want to do any operation if the user clicks on the button for second time. I have the following code. But it is not working. Can someone help??

      $("#myButton").click(function(){
        var count = 0;
        count++;
        alert("button");
        if(count>1)
          $('#myButton').prop('disabled', true);
     });
     <button type="button" id="myButton" > Click Me </button>

This is the FIDDLE

Anoop Joshi

you can use one in jquery for that

$("#myButton").one("click",function(){

It will attach a handler to an event for the element which will executed at most one.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

CSS Animation With jQuery Not Firing on Second Button Click

From Dev

jQuery Disable Button function on second click

From Dev

jquery button click not working second time on fieldset?

From Dev

How to prevent second click on radio button if it was already checked in Android?

From Dev

jquery - change button's text on click works only on second click

From Dev

Programmatically click a button using jquery

From Dev

Programmatically click a button using jquery

From Dev

Click Gridview button using jQuery

From Dev

Prevent space button from triggering any other button click in jQuery

From Dev

Unity Prevent Click On Button

From Dev

Display a Modal on button click using Jquery

From Java

Click button copy to clipboard using jQuery

From Dev

Hide/Show Div on button click using Jquery

From Dev

How to clear effect of a click button using jquery

From Dev

Download image on button click using jQuery

From Dev

Open new tab on button click using JQUERY

From Dev

Delaying the Submit button click using Jquery

From Dev

Remove old data on button click using jquery

From Dev

How to clear effect of a click button using jquery

From Dev

Add Number on Button Click using jQuery?

From Dev

Delaying the Submit button click using Jquery

From Dev

POST form on button click using jquery ajax

From Dev

Open new tab on button click using JQUERY

From Dev

Remove old data on button click using jquery

From Dev

Resize Svg Image Using Jquery on Button click

From Dev

How To Remove Textbox Using Jquery On Button Click

From Dev

Using Jquery to click button to activate/deactivate text

From Dev

How to Trigger an event on button click using jQuery

From Dev

Expanding text with button click using jquery

Related Related

HotTag

Archive