Button Timer Help

Hi Everyone

Was hoping to get some help as to how set a button as hidden when a lightbox opens. And then after say 20 secs the button appears (automatically).

Have been trying to play around with Wix Code setTimeout($w(‘#button’).isVisible, 180000); with no success so far. Also tried button.show().

All help is greatly appreciated.

Hey,

Thanks for the question. There are two approaches to this problem, but first of all, lets hide the button properly:

Hide button by:

1. Enabling Properties Panel — Select "Tools" in Wix header -> Enable "Properties Panel" 
2. Select button and choose "Hidden on Load" from buttons "Properties Panel" 

To unhide button you can use show method, which has 8000ms maximul possible delay:

$w.onReady(function () {
    let fadeOptions = {
        "delay": 8000
    };

    $w("#button1").show("fade", fadeOptions);
});

Or, don’t use the build-in delay option and instead use setTimeout method with unlimited delay, which needs to be wrapped into function:

$w.onReady(function () {
    setTimeout(function(){ 
        $w("#button1").show("fade"); 
    }, 20000);
});

Let me know, if that helps!

Hi Giedrius

I tried the code as below (per suggestion) with button hidden on load. Still not working. I would prefer to use the setTimeout because I need timers 20sec-2 min. Concept being user starts watching video and after watching 3/4 (time set my myself) of video button comes up as watched.

Please, double-check if $w selector is correct — if you are trying to select right button (#button1 is used only as example). Also, keep in mind that this could should rest in Ligthbox Page section.

Let me know, if that’s the way it is!

Hi, i used this code and it worked great at delaying the button however, the button only appears on screen for about a second do you know how I can fix this?