new Waypoint({
element: $(".foo"),
handler: function(direction) {
var offset = this.element.offset().top;
...
},
offset: 35
});
我想用 jQuery 获取元素顶部偏移量。然而,这一行一直给我一个错误:
var offset = this.element.offset().top;
出了什么问题?
最佳答案
使用$(this.element)
。
new Waypoint({
element: $(".foo"),
handler: function(direction) {
var offset = $(this.element).offset().top;
},
offset: 35
});
关于javascript - 航点插件 : how do I get current offset?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35410806/