We all know that scroll to top with named anchors via HTML is possible but is it possible to scroll to the top when another HTML element is clicked that is not surrounded by tags? For instance, a DIV?
EDIT: Apologies all, I did not see this was a duplicate question. I did a search and didn't find anything.
Yes, you might want to do it with Javascript by using
window.scrollTo(0, 0);
and assigning it to the div
<div onclick="window.scrollTo(0, 0);">Element</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With