gpt4 book ai didi

javascript - 更改 var speed 值 onClick?

转载 作者:行者123 更新时间:2023-11-28 08:32:21 26 4
gpt4 key购买 nike

当用户单击按钮时,它将更改 var speed 值。我怎样才能做到这一点?目前,其设置为 1000 毫秒//1 秒,如下行所示:

var increment = setInterval(increment,1000); // gain 1 ever second // THIS IS WHAT I WANT TO CHANGE

我想将按钮的 1000 次点击更改为 2000 次。我想这就是所谓的增量值吧?我只知道它是我设置的在 1000ms 时间内获得数字的速度。

代码链接:

http://pastebin.com/UPaT9n3F

最佳答案

您可以清除间隔并重新创建

$('#element').click(function(){
window.clearInterval(incrementID); //
timing = timing + 1000; //this is if you plan to keep adding up.
incrementID = setInterval(increment, timing);// if not you can always hardcode 2000
});

还有:

var timing = 1000;
var incrementID = setInterval(increment,timing); // gain 1 ever second // THIS IS WHAT I WANT TO CHANGE
//you should change the varname so that you can use the handle to clear the already set interval

关于javascript - 更改 var speed 值 onClick?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21692587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com