Preventing multiple clicks on button

后端 未结 14 1984
小鲜肉
小鲜肉 2020-12-02 09:43

I have following jQuery code to prevent double clicking a button. It works fine. I am using Page_ClientValidate() to ensure that the double click is prevented o

14条回答
  •  执念已碎
    2020-12-02 10:41

    After hours of searching i fixed it in this way:

        old_timestamp == null;
    
        $('#productivity_table').on('click', function(event) {
    
        // code executed at first load
        // not working if you press too many clicks, it waits 1 second
        if(old_timestamp == null || old_timestamp + 1000 < event.timeStamp)
        {
             // write the code / slide / fade / whatever
             old_timestamp = event.timeStamp;
        }
        });
    

提交回复
热议问题