开发者

Cannot read property 'top' of null

开发者 https://www.devze.com 2023-02-03 03:28 出处:网络
I\'m console.logging the offset() of an element and I get left: 1236 top: 139 __proto__: Object But when I log offset().top I get the error

I'm console.logging the offset() of an element and I get

left: 1236
top: 139
__proto__: Object

But when I log offset().top I get the error

Cannot read property 'top' of null

Here's my code in its entirety:

console.log(('.index-title').开发者_如何学编程eq(n).prev().offset().top);


If n's 0, then you're at the start of the list and .prev() has nowhere to go, returning null instead of what would have been the "previous" object in the list.

0

精彩评论

暂无评论...
验证码 换一张
取 消