我有一些像这样的jQuery代码
$(document).ready(function(){
$('.content-nav a').on('click',function(){
var str = $(this).attr("href");
var the_id = str.substr(1);
$("#container").animate({ scrollTop: $(the_id).offset().top }, 1000);
});
});
Run Code Online (Sandbox Code Playgroud)
当我点击链接时,我得到的错误就像 Uncaught TypeError: Cannot read property 'top' of undefined
谁能告诉我什么是错的?
我正在使用从谷歌api加载的jQuery 1.8.3.