and I wan...">

How to recognize the second click on the button

I create a jquery function and call it a link.

<a href="javascript:myfunc(ID)"></a> 

and I want to test my function that the button is the second time or the first time

and I want to do different events on the first and second clicks ()

0
source share
1 answer

You can use .toggle() , for example:

 $("#myButton").toggle(function() { //click oe }, function () { //click two }); 

You can add as much as you want, in fact, it just goes through them. If you need to bomb after the second click, simply .unbind() by adding $(this).unbind('click') at the bottom of the last click function, for example:

 $("#myButton").toggle(function() { //click oe }, function () { //click two $(this).unbind('click'); //without this, it goes back to the first function //on the next click }); 
+5
source

All Articles