Hiding Elements with a toggle

Hey there …

You need to use the switch’s onChange event handler to run your code,

// #1: Creating an event handler
$w('#switchToggle').onChange(event => {
    // #2: Get the switch's current status 
    const switched = event.target.switched; // Either "true" or "false";
    
    // #3: Check whether the swithc is turned on, or off
    if (switched) {
        // The switch is turned on, show the elements
    } else {
        // The switch is turned off, hide the elements
    }
})

Don’t forget to place this code inside the page’s onReady event handler.

Hope this helps~!
Ahmad