Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function not defined in setInterval

Hallo, I've got something like this:

$(document).ready(function(){

 $("#all").height($(window).height()-60);

$('a').bind({
  mouseover:function(){
   $(this).stop().animate({opacity:0.8},500);
 },
 mouseout:function(){
   $(this).stop().animate({opacity:1},500);
 },
   click:function(){
 }
});


// CLOUDS SCROLL 

 function cloudScroll(){
     var current=parseFloat($('#clouds').css('left'));
     current += 1;
     $('#clouds').css("left",current);
 }

var init = setInterval('cloudScroll()', 270);

});

Seems to be quite easy but anyway it returns: cloudScroll is not defined.
Why?

like image 710
Drink86 Avatar asked Dec 08 '10 16:12

Drink86


1 Answers

Try passing the function directly, using a string is quite obsolete:

var init = setInterval(cloudScroll, 270);
like image 92
Kobi Avatar answered Oct 21 '22 05:10

Kobi