@ahmedfghamry
Nope you need to have each one as a separate element, plus you would need to use MouseIn and MouseOut.
Although note that onMouse won’t work with mobile devices obviously, so you can either remove the function for mobile devices or change it to onClick only.
The other option is to make your code up so that the onMouse functions are written for desktop only with the if else part of the code applying to mobile only. See the last two links below for more info about code that only runs on mobile or desktop.
So, back to the code for all your elements, each one will have to be written in the code like this:
export function button2_onMouseIn() { //You will need to make sure that onMouseIn event is on in the properties panel for this to work
//or
$w("#button2").onMouseIn( () => { //This does the onMouseIn inside the code so no need to set it up in the properties panel for the element
$w("#box1").show();
$w("#box2").hide();
$w("#box3").hide();
$w("#box8").hide();
$w("#box9").hide();
}
//Need onMouseOut to tell page what to do when mouse is moved off the button.....
export function button2_onMouseOut() {
//or
$w("#button2").onMouseOut( () => {
$w("#box1").hide();
$w("#box2").show();
$w("#box3").show();
$w("#box8").show();
$w("#box9").show();
}
//rest of code to enter
As you will have a lot of code to add for this to work, an easier option if it is possible on your page, is to put everything in a strip or a container, so that you only have to hide or show the strip and not every element on the page.
You might have already done this with the boxes, however it is much easier having everything grouped so that you only have to close one strip or container etc instead of everything.
Plus, you could always look at changing the boxes and putting them as separate lightboxes instead so that they show up when the button is hovered over or clicked instead. That way you have less on your page and you can position the lightboxes to show up in a certain area of the screen too.
Take a look at this page for example:
https://www.wix.com/code/home/example/Hide-and-Show-Elements#
Plus also the API’s for the others, like Yisrael has already posted above for the wixLocation.
https://www.wix.com/code/reference/wix-window.lightbox.html
HiddenMixin - Velo API Reference - Wix.com
ClickableMixin - Velo API Reference - Wix.com
https://www.wix.com/code/reference/$w.Button.html
Velo: Reacting to User Actions Using Events | Help Center | Wix.com
Velo: Writing Code That Only Runs on Mobile Devices | Help Center | Wix.com //Note that this code for run on mobile device does only work properly on the live site, it might not show correctly on preview, however it does work when site is live.
https://www.wix.com/code/home/forum/community-discussion/need-to-remove-mousein-event-from-mobile-mode