I have a JQuery's .each
loop that calls a function with a parameter per iteration, is there a way to delay this function call? I have tried setTimeout
as in the following but this does not work as the function gets executed immediately.
$.each(myArray, function (j, dataitem)
{
setTimeout(function () { showDetails(dataitem) }, 300);
});
function showDetails(dataitem)
{
...
}
Array size is roughly 20, What I'm trying to do is to distribute function calls over a certain time frame instead of immediately, any idea how to achieve this? I'm prepared to rewrite and restructure how functions get called to get this done, any help would be appreciated.
setTimout
s are more or less called at once. Do you want to call theshowDetail
functions one after another? I mean, the first after 300ms, the second after 600ms, etc. – Alanna