Home >Web Front-end >JS Tutorial >js control button to prevent frequent click responses
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