phil crowe
phil crowe

Reputation: 887

Jquery dont allow button to be pressed

If i have a button pressed method like this:

$('#next').click(function () {
});

How can i stop this method being initiated whilst its running. Say the method takes 5 seconds to run and someone clicks it 3 seconds in it breaks so i want to make the div thats being clicked unclickable while the methods running.

Upvotes: 0

Views: 218

Answers (3)

praveenjayapal
praveenjayapal

Reputation: 38529

You can use "disabled" to disable the button while your execution, as like byron said

Upvotes: 0

Akku
Akku

Reputation: 4454

Replace the clicked link with <p>loading...</p>

Upvotes: 5

Bob
Bob

Reputation: 3084

$('#next').click(function () { 
   $(this).attr("disabled", "disabled"); 
   stuffff
   $(this).attr("disabled", ""); 
});

Upvotes: 7

Related Questions