首先,确保你已经在你的项目中引用了jQuery库。
在你的JavaScript文件中添加以下代码:
$(document).ready(function() { var target = $("#yourdiv"); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top }, 1000); } });
将代码中的“#yourdiv”替换为你想要滚动到的div的ID。
保存并运行你的应用程序,此时页面应该会滚动到你指定的div。