javascript - anchor link - animating page back to page top -
wordpress site; using simple code , anchor send user top of page.
<body id="pg-top" <?php body_class(); ?> > ... <a href="#pg-top">miss something?</a>
this sends user directly top instantly. want user automatically "scrolled up", sent page @ speed.
not sure if explained correctly, i've seen done on many websites. gradual scroll top of page on click
you can use jquery animate
function on hyperlink click event.
<a href="javascript:void(0);" onclick="scrolltop();">miss something?</a>
jquery
<script> function scrolltop(){ $("html, body").animate({scrolltop:0}, '500'); } </script>
you can change animation speed changing duration parameter. here in code 500
.
Comments
Post a Comment