How do I scroll to an element using JavaScript?

You can use an anchor to “focus” the div. I.e:

<div id="myDiv"></div>

and then use the following javascript:

// the next line is required to work around a bug in WebKit (Chrome / Safari)
location.href = "#";
location.href = "#myDiv";

Leave a Comment