Join the Webstudio community

Updated last month

How To Stop Link Component From Scrolling To The Top?

At a glance
I have link "button" which doesn't go to an external website but triggers something in my script, but while it triggers my script it also scrolls back to the top of the site, but I don't want that to happen. How can I overcome this?
J
J
5 comments
Maybe use a button component instead?

And or use e.preventdefault
https://youtu.be/CLY_Kj8Qdr0?si=-PK4Yw1D5I-IQbXj at 35s the define the difference between a link and button. It's a good rule to follow.
Simplistically:
links = link to something
buttons = trigger some action (forms, js, action)
Thank you, I didn't use a button because a long time ago it wouldn't work with my script but somehow now it does work
Add a reply
Sign up and join the conversation on Discord