zoukankan      html  css  js  c++  java
  • 阻止按钮快速点击

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>阻止按钮快速点击</title>
    </head>
    <body>
    
    
    <button onclick="handel_text()">click me</button>
    <script>
        var time_arr = [];
        function handel_text() {
            time_arr.unshift(Date.now());
            if (time_arr.length > 2) {
                time_arr.length = 2;
            }
            if (time_arr.length >= 2) {
                if (time_arr[0] - time_arr[1] < 1000) {
                    return;
                }
            }
            yourFn();
        }
    
        function yourFn() {
            console.log('do success');
        }
    </script>
    </body>
    </html>
  • 相关阅读:
    后台执行linux命令
    日志
    配置文件
    后台
    后台代码注释
    递归建立文件夹
    图片合成
    java.awt.Font
    java-日期取特定值
    linux乱码
  • 原文地址:https://www.cnblogs.com/bagexiaowenti/p/9305662.html
Copyright © 2011-2022 走看看