Instead of trying to describe your setup the technical way (what you are not really capable of) i would recommend you, just to describe what you are trying to achieve regarding your setup, shown on the following pic…
You must understand, that there could be a → BUNCH OF DIFFERENT SOLUTION POSSIBILITIES <— to solve your issue.
You have first to describe your setup in detail and mention all the elements which have been used in your SETUP.
For example…(what can be seen on my setup)…
- Image-1 (BACKGROUND-LAYERED) → HEART
- Image-2 (FOREGROUND-LAYERED) —> CAT-ICON
- 2x Buttons —> Yes + NO
Now you should describe the function you want to be created in detail
SETUP-Description:
I want to generate a BUTTON-TOGGLE-FUNCTION.
Each time you swith between → BUTTON-1 and BUTTON-2 ← it should toggle between 2x different states, switching the BACKGROUND-IMAGE (and also the FOREFROUND-IMAG??? … or just FOREGROUND-IMAGE???,…or jsut BACKGROUND-IMAGE).
As you can see we already dive more into detail.
But wait, since you need a switch/toggle-function → why maybe not just using a → SITCH-BUTTON ← for your purposes. You would just need one button to realize your function. All you would have to do is to position 2x titles —> YES and NO (on left and right side of your switch).
And another question is →
i want to click one, have an image pop up. click again, make the previous image hide and have a new image pop up.
Why you always want to hide one image and show another?
You have the possibility to CHANGE the URL of the IMAGE → what has been shown already in my example. This way you need just one image for toggling-function (changing it’s URL only). Or 2-images if you want the toggle-function for BACK & FOREGROUND.
Using less elements on your Wix-Page → will increase the SPEED of your website!!!
Using more compact CODE on your website → will increase the SPEED of your website aswell!!!
How to create a simple button-toggle-function ?
$w.onReady(()=>{
let button1_state = false;
$w('#button1').onClick(()=>{
if(button1_state===true) {button1_state=false;
console.log('State was setted to FALSE');}
else {button1_state=true;
console.log('State was setted to TRUE');}
});
});
If you want to achieve a different function, then please describe in detail the flow of your setup.