Rakesh Rakesh - 1 year ago 106
Javascript Question

Pass parameters in setInterval function

How to pass parameter while call a function using setInterval.
viz.

setInterval('funca(10,3)',500);
is incorrect.

Answer Source

You need to create an anonymous function so the actual function isn't executed right away.

setInterval( function() { funca(10,3); }, 500 );