Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
每当您在 $('li.item').live('click' 中处理点击时,您需要停止前一个间隔计时器并设置一个新的。这将防止速率增加,因为您有多个间隔计时器正在运行。您必须将 setInterval 的结果存储在适当范围的实例变量中,以便您可以在设置新计时器之前在下次单击时调用clearInterval,这将确保您不会为同一对象同时运行多个计时器。 。
在$('li.item').live('click', 变量 btnclicked 并不总是被定义,这使得函数的其余部分无法执行。
我不明白你关于时间变量的问题。也许你可以更具体关于哪个函数、哪段代码或者时间变量发生了什么。
Whenever you process a click in $('li.item').live('click', you need to stop the previous interval timer and set a new one. This will keep the rate from increasing because you have multiple interval timers running. You will have to store the result from setInterval in an appropriately scoped isntance variable so you can call clearInterval with it on the next click before setting a new timer. This will makes sure you don't have multiple timers running at once for the same object.
In $('li.item').live('click', the variable btnclicked is not always defined which keeps the rest of the function from executing.
I don't understand your question about the time variable. Perhaps you could be more specific about which function and which piece of code or what is happening with the time variable.