CODE - Text animation: 1 second ON and 1 second OFF

Hi all,

I have no idea how to make a code to do the following:

I have made my website using WIX. I would like to make a text line more “dynamic”. The only thing I want this text to do is to switch from 1 second ON to 1 second OFF , I mean, this text has to be visible 1 second and disappear another second, in an infinite loop.

Could anyone help me with this?

Thanks in advance!

$w.onReady(() => {
    setInterval(() => {
        $w("#text1").hidden ? $w("#text1").show() :     $w("#text1").hide();
        }, 1000)
})

Thanks a lot!! It works perfectly :slight_smile:

Can you combine this code for 3 text boxes for example so there would be a loop for three words in the same place?

For example text: Vegetables of the day are TOMATO/ONION/CARROT and this uppercase are showing in the loop one after another.

Thanks in advance!

@rudjersimek
You can do something like:

let vegs = ["TOMATO", "ONION", "CARROT "];
const intevalInSeconds = 1;
let currentVeg = 0;
$w.onReady(() => {
    setInterval(() => {
        $w("#text1").text = vegs[currentVeg];
        currentVeg = (currentVeg + 1) % vegs.length;
    }, intevalInSeconds * 1000);
})

@jonatandor35 This is great! Thank you very much!

Hi, how can I do this but have the transition between text be ‘fade’?

$w.onReady(()=> setInterval(()=> { $w("#text1").hidden ?$w("#text1").show('fade'):$w("#text1").hide('fade');} ,1000));