i have a problem with my ‘setInterval’ function, i’d like to start the function when i’m hovering my div, but the setInterval work just at the first time when i hover the div => if i’m staying on the div, it doesn’t keep on changing the picture, but stop the ‘setinterval’.
Is it a problem with mouseenter? i tried ‘hover’, etc. but nothing seems to make the trick.
Does anyone have a solution?
Thanks a lot for your help, here’s my code :
img.bind('mouseenter', function(){
setInterval(next($(this)),1000);
});
function next(elem){
var img_li = elem.find('li');
count++;
if (count>2) count=0;
img_li.eq(count).fadeIn('fast', function(){
img_li.eq(current).css({'display':'none'});
current = count;
});
}
It is because you are assigning the return value of next($(this)) to the setInterval and not the function itself.
Try this: