How do I make an object (headline) fade after a delay

Using Wix editor. I am trying to have my headline fade out after a set delay. I found this javascript online and have inserted it into my masterPage.js but it’s not working. I gave the container holding the headline the ID #homeHeads.

fadeOptions = {“duration”: 1000, “delay”: 500 };

$w.onReady((=>{
$w(“#homeHeads”).show(“fade”);
setTimeout(()=>{
$w(“#homeHeads”).hide(“fade”, fadeOptions);
},1000)
})

Hi Greg, try this.

Please note it is always better to quote code in this way

let fadeOptions = {"duration": 1000, "delay": 500};

$w.onReady(() => {
    $w("#homeHeads").show("fade");
    setTimeout(() => {
        $w("#homeHeads").hide("fade", fadeOptions);
    }, 1000);
});

Wow. That worked like a charm! I don’t know javascript well so I was just copying and pasting from another post. Thanks so much. Really appreciate it.

1 Like