Home  >  Article  >  Web Front-end  >  js control button to prevent frequent click responses

js control button to prevent frequent click responses

PHPz
PHPzforward
2016-05-16 19:16:491329browse

In order to prevent frequent clicks on the button, a strategy can be adopted. After clicking once, the button will be grayed out, temporarily unavailable, and then available again after a period of time. The pseudo code is as follows:

var clicktag = 0;
            $('.a_cc').click(function () {
                if (clicktag == 0) {
                    clicktag = 1;
                    $(this).addClass("a_bb");
                    alert('click触发了');
                    setTimeout(function () { clicktag = 0 }, 5000);
                }
            });

More related For tutorials, please visit JavaScript Video Tutorial

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete