I would go nuts if I see a code like this...
– IcepickleAug 3 '17 at 16:16

@Bergi sorry, I forgot to take the loop thing out. main is just the way I was taught. To run JS code on load I start with $(document).ready(function() { PUT THE CODE HERE and end with $(document).ready(main);
– Ol_man_coderAug 3 '17 at 16:19

4 Answers
4

This is a simple idea that takes an array of classnames. It would be easy (and maybe better) to grab the elements with a selector, but this should make it easy to use. Now you grab the first element off the array, use it to fade, and put it back on the end of the array. It should continue.

You can simply extract your anonymous function from the $document.ready(). Then, you will call it once inside your $document.ready() and then use .setInterval() to call it again and again every 60 seconds, which is what you want.

I provided a proof of concept that logs to the console every 5 seconds, as a starting point for you:

@Ol_man_coder You would put the $(document).ready call anywhere that the repeatFadeEffect function is in scope (probably the same document). Then call repeatFadeEffect from within its handler.
– Matthew LewisAug 3 '17 at 15:59

1

@Ol_man_coder Updated the answer to reflect a more useable solution in your scenario (assumptions made). Let me know if that makes more sense.
– Jako BassonAug 3 '17 at 16:00

1

@Ol_man_coder as Matthew mentions, you should call the document.ready function to kick start the effect and the rest of your main function logic as per the updated answer.
– Jako BassonAug 3 '17 at 16:03