I have the following function that I would like to run on a continuous loop and I thought this would work for me, but not so because the function only runs once. I am not sure if the problem is with the method, the interval or my code. I am fairly new at this.
var c = $(".test p").length;
setInterval(faderepeat(c),20000);
function faderepeat(c){
var i = 0;
while (i<=c) {
var p = $(".para");
($(p[i]).delay(i*3000).fadeIn(2000).fadeOut(1000));
i++;
}
}
Change your setInterval call to:
The way you are calling it, the function runs once and setInterval calls the result of the function repeatedly.
The problem could be this line:
You cannot pass parameter to callback function this way, try this:
Move
var c =$(".test p").length
intofaderepeat
to always get the latest value.