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

js control button to prevent frequent click responses

PHPz
Release: 2018-10-10 16:15:17
forward
1419 people have browsed it

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);
                }
            });
Copy after login

More related For tutorials, please visit JavaScript Video Tutorial

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template