我有这个功能运行几秒钟使用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) 我希望有一个简单的解决方案.我有一个数据库列,我在其中存储一个数字.我知道数字会变得很大,所以我将字段设置为'bigint'.但是它不会存储大于的数字9223372036854775808.
为什么是这样?