小编use*_*550的帖子

阻止JavaScript函数运行两次(setTimeout)

我有这个功能运行几秒钟使用setTimeout.单击按钮时会运行此功能.

function complete() {
    var div = document.getElementById('log');
    setTimeout(function(){ div.innerHTML = div.innerHTML + intro[Math.floor(Math.random() * intro.length)] + "<br>"; }, 500);
    setTimeout(function(){ div.innerHTML = div.innerHTML + second[Math.floor(Math.random() * second.length)] + "<br>"; }, 2560);
    setTimeout(function(){ div.innerHTML = div.innerHTML + third[Math.floor(Math.random() * third.length)] + "<br>"; }, 4860);
    setTimeout(function(){ div.innerHTML = div.innerHTML + fourth[Math.floor(Math.random() * fourth.length)] + "<br>"; }, 7860);
    setTimeout(function(){ div.innerHTML = div.innerHTML + fifth[Math.floor(Math.random() * fifth.length)] + "<br>"; }, 9640);
}
Run Code Online (Sandbox Code Playgroud)

但是,如果用户多次单击该按钮,则此功能也会开始多次执行.我试图通过使用下面的代码来防止这种情况发生,但是,它无法正常工作.

var running;
function complete() {
    if (running == …
Run Code Online (Sandbox Code Playgroud)

javascript function execution settimeout

4
推荐指数
1
解决办法
1万
查看次数

Mysql不会使用bigint存储大于9223372036854775808的数字

我希望有一个简单的解决方案.我有一个数据库列,我在其中存储一个数字.我知道数字会变得很大,所以我将字段设置为'bigint'.但是它不会存储大于的数字9223372036854775808.

为什么是这样?

mysql sql

-1
推荐指数
1
解决办法
1774
查看次数

标签 统计

execution ×1

function ×1

javascript ×1

mysql ×1

settimeout ×1

sql ×1