top of page
Anchor 1
Wix Tutorial - Change a Link, using Wix Code
This tutorial will show you how to change button links for different scenarios using Wix Code. You will be able to direct visitors to different webpages based on their user input.
Elements:
User Input:
-
Dropdown: #DropDown1 | Pinned & Show on all pages
Elements:
-
More Information Button: #MoreInfo
External URLs:
-
Website 1 (insert URL 1)
-
Website 2 (insert URL 2)
Wix Code (on site tab):
import wixLocation from 'wix-location';
export function GoToWebsite_click(event, $w) {
let option = $w("#dropdown1").value;
if ( option === "website1" ) {
wixLocation.to("URL1");
} else {
wixLocation.to("URL2");
}
}
Demo:
bottom of page