JS控制按钮防止多次点击

来源:互联网 发布:启动mysql 编辑:程序博客网 时间:2024/06/05 01:00


<!DOCTYPE html><html><head>    <title></title>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    <script type="text/javascript">        // 按钮防止短时间多次点击        //全局变量标识        var CLICKTAG = 0;        function button_onclick(pElement){            if (CLICKTAG == 0) {                  CLICKTAG = 1;                  pElement.disabled=true;                // 等待3s后重置按钮可用                setTimeout(function () { CLICKTAG = 0 ; pElement.disabled=false;}, 3000);              }        }    </script></head><body>    <input type="button"  style="width:125px;height:25px;" value = "点击" onclick="button_onclick(this)" ></button></body></html>