The presence of this HTML is:
<a href="#test">link</a> <div id="test"></div>
You can not scroll the div element and instead scroll to the top of the window with this code:
$("a").on("click", function(e) { e.preventDefault(); window.scrollTo(0, 0); });
EDIT:
You can try adding this:
var firstVisit = true; $(window).scroll(function() { if (firstVisit) { window.scrollTo(0, 0); firstVisit = false; } });
Dim13i Nov 24 '14 at 1:33 2014-11-24 01:33
source share