I want to be able to scroll back to the top of my page by the click of a button. I'm trying to use JS for this, using a function for this that is triggered by an on-click event listener. Array.from(document.querySelectorAll('.save-btn')).forEach(btn => { btn.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); alert('hello') }) }) The alert with ‘hello’ is being triggered (just to test if anything happens at all), but it doesn't scroll back to the top. I’ve also tried the ‘scrollTo’ method using pure HTML and JS and it does work, so it is a valid function. Any suggestions on how to tackle this?
asked
Marijn Gaikema
3 answers
3
Take a look at the “Scroll To” action in the Web Actions module. You just need to call this from a nanoflow.