Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

javascript - wix - onClick() color change for button

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)"

        }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...