tags:

views:

27

answers:

1

i make a jquery function and called it by linking.

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

and i want to check in my function that button is second time click or first time

and i want to make different different event on first and second click()

+3  A: 

You can use .toggle(), like this:

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

You can add as many as you want actually, it just cycles through them, If you need to bomb out after the second click, just .unbind() by adding a $(this).unbind('click') at the bottom of the last click function, like this:

$("#myButton").toggle(function() {
  //click oe
}, function () {
  //click two
  $(this).unbind('click'); //without this, it goes back to the first function
                           //on the next click
});
Nick Craver
please read my question i edit it after your answer.
4thpage
@4thpage - Does it *have* to be in-line? Giving the link an unobtrusive/external handler would be a much better approach if possible.
Nick Craver