不在谷歌上,不管我怎么努力:(
有由ajax动态生成的内容,加载后,您需要在没有点击的情况下滚动。
通过 on("click", ) 有很多解决方案 - 但我没有点击 - 我需要在加载页面时滚动到所需的锚点,我该怎么办?
例如,
var el = "#review-1261";
$("html, body").animate({ scrollTop: $(el).offset().top }, "slow");
而块是<div id="review-1261"></div>通过ajax加载的
控制台抱怨:
jquery.min.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'top')
解决方案: