This is my first time building a loop in jQuery or js, and I've gotten myself over my head.
I have a piece of content that needs to loop on page load:
<li id="nav_about"><a href="">Loren ipsum <span id="adjective">1</span></a>
</li>
At a regular interval to go down the following functions (swapping text out), and then once the loop reaches the last function, to return to the top and start it all over again.
{$("#adjective").fadeOut(500).delay(100).text("2").fadeIn(500);}
{$("#adjective").fadeOut(500).delay(100).text("3").fadeIn(500);}
{$("#adjective").fadeOut(500).delay(100).text("4").fadeIn(500);}
{$("#adjective").fadeOut(500).delay(100).text("1").fadeIn(500);}
I know I need to use setInterval
, define a variable, and create a function here somehow, but honestly I'm lost as to how the pieces go together.
My gut level guess is that even this is a rather clunky way of achieving this, and there's likely a method of defining the .text terms as variables in an array as to avoid the multiple .fadeOuts and .fadeIns.
Could sure use some help here.