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
Post a Comment