wix - onClick() color change for button

Viewed 626

really new to everything related to coding.

I have a project in uni where we need to create a website in wix for a store. I intended to have a menu with green buttons and for the button color to change when clicked (e.g: going from page a to page b, you'll click on page b and when this happens, the button should change to blue).

After several hours on research I have a video which was demonstrating the functionality for a box, I thought I would apply the same to a button but no luck (nothing changes at my end). Any ideas would be highly appreciated. Thanks a lot!

$w.onReady(function () {
});

export function ShoesPageButton_click(event){

        if($w("#ShoesPageButton").style.backgroundColor==="rbga(53, 91, 53, 1)"){

        $w("#ShoesPageButton").style.backgroundColor="rgba(127, 204, 247, 1)"

        }else{

        $w("#ShoesPageButton").style.backgroundColor="rgba(53, 91, 53, 1)"

        }
}
1 Answers

You have a typo, instead of "rgba" you have written "rbga" on the 1st line of the if statement.

$w("#ShoesPageButton").style.backgroundColor === "rgba(53, 91, 53, 1)"

Also not sure I understood "going from page a to page b, you'll click on page b and when this happens, the button should change to blue" - Are you trying to say that the click is occurring on page A and the button is on page B?

Related