I’m trying this code but it 's not working:
import wixLocation from ‘wix-location’;
let x = 1;
$w.onReady( function () {
});
export function button1_click() {
if (x === 0) {
wixLocation.to(‘/anchor-session#anchor1’); //Linking to anchor with wixLocation API
console.log(“anchor1”);
x = 1;
} else {
wixLocation.to(‘/anchor-session#anchor3’);
console.log(“anchor3”);
x = 0;
}
if ($w(‘#gallery1’).collapsed) {
$w(‘#gallery1’).expand();
}
else
$w(‘#gallery1’).collapse();
if ($w(‘#gallery2’).expand) {
$w(‘#gallery2’).collapse();
}
}
I have 2 Anchor Points:
Anchor Point 1: On a particular page session.
Anchor Point 2: At the top of the page.
I would like to do this:
When the user clicks the button it is directed to Anchor Point 1 and when it clicks again was taken to Anchor Point 2.
Any suggestions?