设为首页收藏本站 国外访客:

 找回密码
 立即注册
搜索
查看: 26243|回复: 0

限制按钮点击次数加统计次数

[复制链接]
  • 打卡等级:暂无等级
  • 打卡总天数:248
  • 打卡月天数:13
  • 打卡总奖励:204
  • 最近打卡:2026-01-22 02:18:50
灌水成绩
15724
58
2037035
主题
帖子
积分

等级头衔

ID : 1

管理员

积分成就 威望 : 999899
贡献 : 9999
下载币 : 11456
在线时间 : 1257 小时
注册时间 : 2013-9-5
最后登录 : 2026-1-22

发表于 2025-10-26 01:27:51 | 显示全部楼层 |阅读模式
免责
[编号:13678]


限制按钮点击次数加统计次数
  1. <body>
  2. <button id="clickButton">点击我</button>
  3. <p id="message"></p>
  4. <p>点击次数: <span id="clickCount">0</span></p>
  5. <script>
  6. let count = 0;
  7. let lastClickTime = 0;
  8. const button = document.getElementById('clickButton');
  9. const display = document.getElementById('clickCount');
  10. const message = document.getElementById('message');

  11. button.addEventListener('click', () => {
  12. const currentTime = new Date().getTime();
  13. if (currentTime - lastClickTime < 5000) { // 限制5秒内只能点击一次
  14. message.textContent = '请等待5秒后再试';
  15. return;
  16. }
  17. lastClickTime = currentTime;
  18. count++;
  19. display.textContent = count;
  20. message.textContent = '';
  21. });
  22. </script>
  23. </body>
复制代码


免责
帖子地址打造全网最多免费游戏网站,部分资源失效,私聊站长补
今日来客 列表模式
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|蔡州手游 |网站地图 wapmz.com

GMT+8, 2026-1-22 04:38