【发布时间】:2012-07-25 20:50:57
【问题描述】:
我使用了这个 sn-p,它工作得很好,但是如果 firebug 控制台说“递归太多”,firefox/firebug 就会死掉。这是一篇有类似问题的帖子,我觉得没有正确解决Jquery Too Much Recursion Error
有没有办法让这个颜色动画连续循环而不产生这个递归问题?如果没有,我怎样才能让它在没有递归的情况下工作?指定距离结束还有多长时间?
$(document).ready(function() {
spectrum();
function spectrum(){
var hue = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
$('#welcome').animate( { backgroundColor: hue }, 1000);
spectrum();
}
});
【问题讨论】:
-
当你只想运行一个周期性任务时不要使用递归。尝试使用 setTimeout 或类似...
标签: jquery firefox recursion firebug