Javascript scroll to div id [closed]
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've searched on google the solution to my problem, and I can't understand why the code I've written work to all, but to me don't. I've written this: <head> <meta charset="utf-8" /> <title></title> <script type="text/javascript"> function scrollTo() { $('html, body').animate({ scrollTop: $('#div_id').offset().top }, 'slow'); return false; } </script> <style type="text/css"> .uno { height: 1000px; background: #808080; } .due { margin-top: 300px; height: 500px; background: #ff00ff; } </style> </head> <body> <div class="uno" onclick="scrollTo()