未捕获的类型错误:无法读取未定义的属性“top”
Uncaught TypeError: Cannot read property 'top' of undefined
我有一些这样的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);
});
});
当我单击链接时,我收到类似Uncaught TypeError: Cannot read property 'top' of undefined
的错误
有人可以告诉我出了什么问题吗?
我正在使用从谷歌 API 加载的 jQuery 1.8.3。
如果the_id
是 id,那么你需要
$('#'+the_id).offset().top
相关文章:
- TypeError:无法读取属性'推'未定义的JavaScript
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 未捕获的类型错误:无法读取属性'删除'的未定义
- AngularJS指令出错-无法读取属性'编译'的未定义
- 看到“;未捕获的类型错误:无法读取属性'weight'未定义的“;尽管按照字面上的指示
- angularjs无法读取未定义的属性then
- 无法读取属性'材料'未定义的Three.js
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- JavaScript承诺-无法读取属性'那么'的未定义
- 未捕获的类型错误:无法读取属性'中止'的未定义
- 角度推入数组给出:TypeError:无法读取属性'推'的未定义
- Javascript未捕获类型错误:无法读取属性'0'的未定义
- jQuery控制台错误:无法读取属性'top'的未定义
- TypeError:无法读取属性'findAll'的未定义
- 无法读取属性'errcap'未定义的jqgrid
- 无法读取未定义的属性“rid”
- 未捕获的类型错误: 无法读取未定义的属性“图像”
- 可以't读取'getHTML'未定义的Liferay CK Editor内容
- 在node.js中未定义读取属性错误