Hi all,
Probably a really simple one. I have a button and have assigned on click some JavaScript to it. JS is working fine but the button scrolls to the top of the page even though I have no interactions set.
Any ideas?
Best wishes,
Ashley
Hi all,
Probably a really simple one. I have a button and have assigned on click some JavaScript to it. JS is working fine but the button scrolls to the top of the page even though I have no interactions set.
Any ideas?
Best wishes,
Ashley
Thats because the button will have an href="#"
attribute. Basically an anchor to the top of the page, that the browser will action.
If you add a preventDefault()
to your javascript it should prevent this from triggering the scroll.
Thank you. I’ll have a play later.