在这个带有 $(this) 的例子中,即使它应该也不起作用。但是,如果我通过将它与 # 连接来获得 id,它确实如此,这很奇怪。我不明白。
$('.myelement').waypoint({handler: function(dir) {
if (dir === 'up') {
// $(this).addClass("waypoint-here");
// $(this).next().removeClass("waypoint-here");
$('#'+this.element.id).addClass("waypoint-here");
$('#'+this.element.id).next().removeClass("waypoint-here");
}
}}, {
offset: '0'
});