1

it only crashes when i see it "live", inside jsbin seems to be working

var counter = 1;
var out = function nextNum() {
counter++;
var numArray = ["1","2","3"];
$('<span id="news' + counter + '" style="display:block; width:20px; height:20px;" />')
.html( Math.floor(Math.random()*numArray.length) ).appendTo('.div1')
.hide().fadeIn(100, function(){if(counter <= 20) nextNum();});};
(out)();


setInterval(rnd,1000);
function rnd() {
var letter = ["1","2","3"];
for (var spanum = 1;; spanum++)
$( "#news" + spanum ).html( Math.floor(Math.random()*letter.length) );}

http://jsbin.com/IQuxevu/4/edit

what am i doing wrong?

4

1 回答 1

1

There is an infinite loop in your code:

for (var spanum = 1;; spanum++)

There is no break inside the loop. It works on JSFiddle because there is an infinite-loop protection as suggested by console warnings.

于 2013-10-15T17:57:27.963 回答