javascript - HTML jQuery smooth scroll to element and add class -


i have in html this:

<!doctype html> <html> <head> <meta charset="utf-8">  <title>stackoverflow please</title>   </head> <body> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>         <div id="scrollhere">scroll here!</div>     <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> </body> </html> 

and when open page: http://example.com/index.html#scrollhere scrolled element, wan't smoothly scroll, , add class element. how can this? much.

try jquery solution:

<!doctype html>  <html>    <head>    <meta charset="utf-8">    <title>stackoverflow please</title>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>    <script>      $(document).ready(function() {                      $('html, body').animate({          scrolltop: $("#scrollhere").offset().top        }, 2000);      });    </script>    </head>    <body>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <div id="scrollhere">scroll here!</div>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>    <br>  </body>    </html>


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -