Hey, guys!
I need to turn a hover box into a link to function like a button since character spacing cannot be adjusted on buttons and it’s making things look bad. I’ve been able to hobble together code from various forums posts and make the container box into a link, but I can’t quite figure out how to make it link to an anchor.
Current code:
import wixLocation from ‘wix-location’ ;
$w . onReady ( function () {
$w ( “#box1” ). onClick ( ( event ) => {
wixLocation . to ( “???” );
})
});
Any insight would be greatly appreciated.
Thank you!
Yes! Thank you! Any tips on getting this to function as an OnClick type thing? Messed around with this ScrollTo stuff for a while and haven’t been able to get it to work.
And now with this knowledge you simply add your wished functionality to scroll the page to a specific page-position.
import wixWindow from 'wix-window';
wixWindow.scrollTo(100, 500);
Let’s put all together…
import wixWindow from 'wix-window';
$w.onReady(()=>{
$w('#elementID').onClick(()=>{
wixWindow.scrollTo(100, 500);
});
});
It already looks like some kind of working code.
But i just recognize that my answer was not 100% correct.
This code gives you the possibility to scroll to a certain specific position, but what you need is…
$w("#myElement").scrollTo();
This one will alwasy scroll to a specific ELEMENT, instead to a specific POSITION.
So, if you have an element somewhere on the very bottom of your page (let it be an IMAGE) and you want to scroll down to this pic by a button click, then you can use this code. Importing of Wix-Window-API is not neccessary in this case, since this function is already integrated in the most of elements.