如何找到第二次点击按钮

我创建一个jquery函数并通过链接调用它。
<a href="javascript:myfunc(ID)"></a>
我想检查我的功能,该按钮是第二次点击或第一次 我想在第一次和第二次点击时做出不同的不同事件()     
已邀请:
您可以使用
.toggle()
,如下所示:
$("#myButton").toggle(function() {
  //click first time 
}, function () {
  //click second time
});
你可以添加你想要的实际数量,它只是循环它们,如果你需要在第二次点击后弹出,只需通过在最终点击功能底部添加
$(this).unbind('click')
,3ѭ,如下所示:
$("#myButton").toggle(function() {
  //click first time 
}, function () {
  //click second time
  $(this).unbind('click'); //without this, it goes back to the first function
                           //on the next click
});
    

要回复问题请先登录注册