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()
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()
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
});