user701510 user701510 - 7 months ago 75
Javascript Question

function in setInterval() executes without delay

I am in the process of making a jquery application to hide an image after a specified interval of time by using setInterval(). The problem is that the hide image function executes immediately without delay.

$(document).ready(function() {

setInterval(change(), 99999999);

function change() {
$('#slideshow img').eq(0).removeClass('show');



I am testing it in jsfiddle.


You called the function immediately instead of passing it to setInterval.

setInterval( change, 1500 ) - passes function change to setInterval

setInterval( change(), 1500 ) - calls the function change and passes the result (undefined) to setInterval