Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll To Top When DIV Clicked? [closed]

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.

like image 816
Aaron Brewer Avatar asked Nov 05 '12 19:11

Aaron Brewer


1 Answers

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>
like image 103
ianaz Avatar answered Sep 22 '22 23:09

ianaz