Changing text loop

@alydelpalacio Ok, so it’s pretty simple. I made a container which I put the 3 texts I wanted to rotate between in (You can do more or less). I set the container’s Overflow content to Hide, and I set all 3 texts to hidden.

I called the container #Sec1WordHolder then I simply ran this code

import wixAnimations from 'wix-animations';
$w.onReady(function () {
// Saves all the elements in the #Sec1WordHolder container
    let sec1WordArray = $w("#Sec1WordHolder").children

    // Runs trough the list of elements to show
    sec1ExchangeWords(sec1WordArray)
})

function sec1ExchangeWords(elementArray) {
    //Runs the method on repeat with 2 seconds delay between each-
    sec1IntervalID = setInterval(function () {
        
        elementArray[sec1CurrWord].hide("glide", sec1HideWordOption);

        //If it's displayed all, returns to the first one
        if (sec1CurrWord != elementArray.length - 1) {
            sec1CurrWord++;
        } else {
            sec1CurrWord = 0;
        }
        elementArray[sec1CurrWord].show("glide", sec1ShowWordOption)
    }, 2000)
}

Hi @volkaertskristof

Thank you for this code. I was able to use this on my site. How do you speed up the rotation of the words?

I tried adjusting both the timeInterval and “duration” / “delay,” but it messed things up.

Thanks in advance,
Elizabeth

I did exactly described here. But its not working for me. What am I missing?

Mine is giving the warning like “Cannot find name Sec1IntervalID” and for others also

The real question is: how do we add hyperlinks to each word? Would you have to create a container for each word that is linked to another page, and somehow figure out how to rotate the containers?

Hi.
How can I use this code to change sentences from a database, not from within the code itself?